//十滴水游戏
//核心函数为count,play,draw,mouse_count,draw_scene
#include <windows.h>
#include <stdio.h>
#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>	
#include <io.h>//用于检查文件是否存在
#define height 800 
#define width 1300
#define time_distance 12//水滴每运动一格的帧率，仅供参考
#define TIME 10//游戏停顿时间
#define MAX_LIST 52//最大表格长宽，含缓冲，实际(MAX_LIST-1)
clock_t start=0, now=0;//前两个变量为计时器，便于控制程序运行时间。
int rgb[10][3] = { { 0,0,0 },{50,165,50},{207,23,13},{137,36,216},{30,30,142},
	{0,0,0}, { 60,191,57 } ,{232,25,14},{153,41,242},{35,36,168} };//颜色数组前五个为填充后五个为边框
int rgb_average[5][3]{ { 0, 0, 0 },{ 55, 178, 54 },{ 220, 24, 14 },{ 145, 39, 229 },{ 33, 33, 155 } };//颜色平均值
int rgb_now =1;//当前颜色
int game_random[5] = { 20,15,12,10,0 };//以一百为标准，里面是每个水滴数量的比例，1-4
int row =20, column =20,row_max=10,column_max=10,column_min=3,row_min=3,row_column_random=0;//行列以及随机最大最小,随机启动判定
int max = 5;//水滴数量阈值
float distance = 0, distance_half = 0;//表格距离
int x_0 = 300, y_0 = 100;//初始位置
int x_1 = 900, y_1 = 700;
int x_mouse=0, y_mouse=0, n_mouse = 0,time_mouse = 0;//鼠标的坐标，是否获取，缓冲时间
int num_water_use = 0, num_water_boom = 0, num_water_begin = 10, currentValue = 0,num_water_all=0,num_water_all_begin=0;//水滴点击数，炸裂数，初始数，可用数,水滴总数,水滴初始总数
int num_water_I_begin =10;//自定义水滴初始数
int scene = 5;//打开的界面的编号
int game_scene = 3;//游戏的结局返回的编号，0代表正在游戏中，1代表再来一次，2代表退出上级界面,3为非游戏内界面,4代表结局界面
int water_over = 0,ice_over = 0;//判断场上是否有水滴移动，是否有水滴
int j = 0,k=0,time_r=0;//没什么用的参数，主要判断游戏函数是否退出,奖励水滴的发放,保卫模式的加速
int mouse_late = 0;//鼠标点击后结局判断延迟的标记
int water_mode =3;//分为1,2,3,4,1为普通模式，2为炸弹，3为核弹,4为保卫模式
int mode_4 = 3;//难度选择，1为简单，2为普通，3为困难,4为自定义
int fight_1 = 0, fight_2 = 0, fight_3 =0,fight_4=0,HP=10;//保卫模式的外挂，1为火力支援，2为核弹打击，3为坚不可摧,4为闪电战
int game_random_mode_4[5]= { 30,15,15,15,5 };//保卫模式的水滴数量比例
int boom_max = 80;//水滴炸裂奖励极限
int time_open = 1;//计时器结局是否开启
float play_time = 12;//游戏开始时间，秒
float math_circle_size[1000] = { 0.00,0.00,0.01,0.01,0.02,0.02,0.03,0.03,0.04,0.05,
0.05,0.06,0.06,0.07,0.07,0.08,0.09,0.09,0.10,0.11,0.12,0.12,0.13,
0.14,0.15,0.16,0.17,0.18,0.19,0.20,0.21,0.22,0.23,0.24,0.25,0.27,
0.28,0.29,0.30,0.32,0.33,0.34,0.35,0.37,0.38,0.40,0.41,0.42,0.44,
0.45,0.47,0.48,0.49,0.51,0.52,0.54,0.55,0.57,0.58,0.59,0.61,0.62,
0.64,0.65,0.66,0.68,0.69,0.70,0.71,0.73,0.74,0.75,0.76,0.77,
0.78,0.79,0.80,0.81,0.82,0.83,0.84,0.85,0.86,0.87,0.88,0.89,0.89,0.90,0.91,
0.91,0.92,0.93,0.93,0.94,0.95,0.95,0.96,0.96,0.97,0.97,0.98,0.98,0.99,0.99,1.00 };//物理拟合圆的弧度与面积的关系
float math_circle_hudu[1000] = { 0.00,0.03,0.06,0.09,0.12,0.15,0.18,0.21,0.24,0.27,0.30,0.33,
0.36,0.39,0.42,0.45,0.48,0.51,0.54,0.57,0.60,0.63,0.66,0.69,0.72,0.75,0.78,
0.81,0.84,0.87,0.90,0.93,0.96,0.99,1.02,1.05,1.08,1.11,1.14,1.17,1.20,1.23,
1.26,1.29,1.32,1.35,1.38,1.41,1.44,1.47,1.50,1.53,1.56,1.59,1.62,1.65,1.68,
1.71,1.74,1.77,1.80,1.83,1.86,1.89,1.92,1.95,1.98,2.01,2.04,2.07,2.10,2.13,
2.16,2.19,2.22,2.25,2.28,2.31,2.34,2.37,2.40,2.43,2.46,2.49,2.52,2.55,2.58,
2.61,2.64,2.67,2.70,2.73,2.76,2.79,2.82,2.85,2.88,2.91,2.94,2.97,3.00,3.03,3.06,3.09,3.15, };
int score_max[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};//最高分记录,0什么都不记录,1-3;4-6;7-9;10-12;
struct condition//每个格子的状态
{
	int num;//有几个固定水
	int up;//有几个喷射水,[5]表示5种颜色
	int down;
	int left;
	int right;
};
condition game[MAX_LIST][MAX_LIST];//仅存储1-50
condition game_temp[MAX_LIST][MAX_LIST];//临时存储
void max_input();//读取最高分
void clock_sleep();//控制程序运行精确时间
int randombetween(int a, int b);//随机数
void game_begin();//初始化全都为0和行列
void input_game();//输入数据
void game_fuzhi(struct condition a[MAX_LIST][MAX_LIST], struct condition b[MAX_LIST][MAX_LIST]);//将结构体a复制到结构体b
void condition_water_num();//更新固定水滴数量
void condition_update();//更新运动水滴状态
void condition_left();//左移一格
void condition_left_again(int t,int m);//判定什么时候左移
void draw_ice(float x, float y, int row, int column, int n_water);//绘制固定水滴
void draw_water(float x, float y, int row_0, int column_0, int j);//绘制运动水滴
void draw_lines(); // 绘制网格线
void draw_word();//绘制文字
void mouse();//检测鼠标左键坐标
void mouse_count();//根据鼠标坐标计算各种坐标
void mouse_water();//根据鼠标坐标增加水滴
void mouse_result_100();//自定义结局
void continue_result();//重新开始的结局处理
void begin();//游戏内初始化总函数
void count(int p);//游戏内计算总函数
void play();//游玩过程的通用函数
void draw(int p);//游玩内绘制总函数
void bug();//超出边界警告
void draw_circle();//绘制显示水滴数量的函数
void circle_time();//绘制计时圆与火力增援
void game_over();//游戏结束
void draw_scene_0();//初始界面设置绘制
void mouse_scene_0();//初始界面设置鼠标
void draw_scene_1();//第1模式绘制
void mouse_scene_1();//第1模式鼠标
void draw_scene_2();//第2模式绘制
void mouse_scene_2();//第2模式鼠标
void draw_scene_3();//第3模式绘制
void mouse_scene_3();//第3模式鼠标
void draw_scene_4();//第4模式绘制
void mouse_scene_4();//第4模式鼠标
void draw_scene_5();//第5模式绘制
void mouse_scene_5();//第5模式鼠标
void draw_scene_51();//第5模式第1界面密度设置绘制
void mouse_scene_51();//第5模式第1界面密度设置鼠标
void draw_scene_52();//第5模式第2界面方格设置绘制
void mouse_scene_52();//第5模式第2界面方格设置鼠标
void draw_scene_53();//第5模式第3界面颜色效果设置绘制
void mouse_scene_53();//第5模式第3界面颜色效果设置鼠标
void draw_scene();//不同非游戏界面场景绘制
void score_max_update();//历史最高分更新
int main()
{
	max_input();//最高分读取
	initgraph(width, height);
	scene = 0;//初始化界面
	while (1)
	{
		mouse();//获取鼠标位置
		mouse_count();//根据鼠标位置和界面执行对应函数
		draw_scene();//根据界面绘制
		if (game_scene == 0)
			play();//第三极界面开始游戏
	}
	_getch();
	return 0;
}
void clock_sleep()//控制程序运行精确时间
{
	static clock_t start = clock(); // 静态变量保持时间戳
	clock_t now = clock();

	// 计算经过的时间（毫秒）
	int elapsed = static_cast<int>(1000.0 * (now - start) / CLOCKS_PER_SEC);
	// 计算剩余时间
	int remaining = TIME - elapsed;

	// 如果剩余时间大于0，才进行休眠
	if ((water_mode == 1) && remaining > 0) 
	{
		// 使用 busy-waiting 实现更精确的延时
		clock_t end_time = now + static_cast<clock_t>(remaining * CLOCKS_PER_SEC / 1000);
		while (clock() < end_time) 
		{
			// 空循环，等待时间到达
		}
		play_time -= static_cast<float>(TIME) / 1000;
	}
	else if (water_mode == 4)
	{
		if(fight_4 == 1)
			play_time += static_cast<float>(elapsed) / 1000;//闪电战
		else 
		{
			if (remaining > 0) {
				clock_t end_time = now + static_cast<clock_t>(remaining * CLOCKS_PER_SEC / 1000);
				while (clock() < end_time)
				{
					// 空循环，等待时间到达
				}
			}
			play_time += 0.01;
		}
	}
	else
		play_time -= static_cast<float>(elapsed) / 1000;
	// 更新开始时间为当前时间
	start = clock();
}
void max_input()//读取最高分
{
	FILE* fp;
	if (_access("test.txt", 0) == -1) {
		// 文件不存在，创建文件并写入初始数据
		fopen_s(&fp, "test.txt", "w"); // 打开文件，以写方式打开
		if (fp == NULL) {
			printf("文件创建失败！\n");
			exit(0);
		}
		for (int i = 0; i < 13; i++) {
			fprintf(fp, "%d ", score_max[i]); // 将初始数据写入文件
		}
		fclose(fp); // 关闭文件
	}
	fopen_s(&fp, "test.txt", "r"); // 打开文件，以读方式打开
	if (fp == NULL) 
	{
		exit(0);
	}
	for (int i = 0; i < 13; i++)
	{
		fscanf_s(fp, "%d", &score_max[i]); // 从文件中读取数据
	}
	fclose(fp); // 关闭文件
}
int randombetween(int a, int b)//随机数
{
	int r = rand() % (b - a + 1) + a;
	return r;
}
void game_begin()//初始化全都为0和行列
{
	for (int i = 0; i <= (MAX_LIST-1); i++)
	{
		for (int j = 0; j <= (MAX_LIST-1); j++)
		{
			game[i][j].num = 0;
			game[i][j].up = 0;
			game[i][j].down = 0;
			game[i][j].left = 0;
			game[i][j].right = 0;
		}
	}
	num_water_use = 0;
	num_water_boom = 0;
	if (row_column_random == 1) {
		do {
			row = randombetween(row_min, row_max);
			column = randombetween(column_min, column_max);
		} while (row - column > 3 || column - row > 3);
	}
	num_water_all = row*column;
	num_water_begin = num_water_I_begin;
	ice_over = 1;
	water_over = 1;
	int p = row;
	if (column > row)
		p = column;
	distance = (float)(x_1 - x_0) / p;
	distance_half = distance/2;
	if (water_mode == 2 || water_mode == 3)

		play_time = 12;
	else if (water_mode == 1)
		play_time = 10;
	else if (water_mode == 4)
		play_time = 0;
	k = 0;
	boom_max = 62 + mode_4 * 8;
	game_random_mode_4 [0] = {15+mode_4*5};
	game_random_mode_4[1] = { 11 +mode_4 *2};
	game_random_mode_4[2] = { 10};
	game_random_mode_4[3] = { 20-mode_4 *5};
	game_random_mode_4[4] = { 5 - mode_4*5 };
	if (game_random_mode_4[4] < 0)
		game_random_mode_4[4] = 0;
	time_r = 0;
	HP = 10;
	if (fight_3 == 1)
		HP = 1000;
}
void input_game()//输入数据
{
	for (int i = 1; i <= row; i++)
	{
		int j = 1;
		if (water_mode != 4)
		{
			for (; j <= column; j++)
			{
				int p = randombetween(1, 100);
				if (p <= game_random[0])
					game[i][j].num = 1;
				else if (p <= game_random[0] + game_random[1])
					game[i][j].num = 2;
				else if (p <= game_random[0] + game_random[1] + game_random[2])
					game[i][j].num = 3;
				else if (p <= game_random[0] + game_random[1] + game_random[2] + game_random[3])
					game[i][j].num = 4;
				else if (p <= game_random[0] + game_random[1] + game_random[2] + game_random[3] + game_random[4])
					game[i][j].num = 5;
				else
					num_water_all -= 1;
			}
		}
	}
	num_water_all_begin = num_water_all;

}
void game_fuzhi(struct condition a[MAX_LIST][MAX_LIST], struct condition b[MAX_LIST][MAX_LIST])//将结构体a复制到结构体b
{
	for (int i = 1; i <= row; i++)
	{
		for (int j = 1; j <= column; j++)
		{
			b[i][j].num = a[i][j].num;
			b[i][j].up = a[i][j].up;
			b[i][j].down = a[i][j].down;
			b[i][j].left= a[i][j].left;
			b[i][j].right= a[i][j].right;
		}
	}
}
void condition_water_num()//更新固定水滴数量
{
		for (int i = 1; i <= row; i++)
		{
			for (int j = 1; j <= column; j++)
			{
				if (game[i][j].num >= 1)
				{
					if (game[i][j].num >= max)
					{
						int t = 2;
						if (game[i][j].num <= 6)
							t = 1;
						else if (game[i][j].num >= 12)
							t = 4;
						game[i][j].num = 0;
						game[i][j].up += t;
						game[i][j].down += t;
						if(water_mode!=4)
						game[i][j].left+= t;
						game[i][j].right += t;
						num_water_boom++;
						water_over = 1;//表示有移动水
						if (num_water_boom == 1)//计时开始
						{
							if (water_mode == 2||water_mode==3)
							{
								play_time = 12;
							}
							else if (water_mode == 1) {
								play_time = 10;
							}
							else if (water_mode == 4) {
								play_time = 0;
								game[7][2].right += 14;
								game[14][2].right += 14;
							}
						}
					}
				}
			}
		}
		currentValue = -num_water_use + num_water_begin + num_water_boom;
}
void condition_update()//更新运动水滴状态
{
		water_over = 0;
		game_fuzhi(game, game_temp);//复制game到game_temp
		for (int i = 1; i <= row; i++)
		{
			for (int j = 1; j <= column; j++)
			{
					if (game[i][j].up >= 1)
						//水向上，若上方有且颜色相同，则合并，否则向上喷射
					{
						water_over = 1;
						int num = game[i][j].up;//水滴数量
						game_temp[i][j].up = 0;//水滴射出，当前位置清空
						if (game_temp[i - 1][j].num >= 1)
						{
							game_temp[i - 1][j].num += num;
							if(game[i - 1][j].num+num>=8)
							game_temp[i - 1][j].up += game[i - 1][j].num+num-6;
						}
						else
							game_temp[i - 1][j].up += num;
					}
					if (game[i][j].down >= 1)
						//水向下，若下方有且颜色相同，则合并，否则向下喷射
					{
						water_over = 1;
						int num = game[i][j].down;//水滴数量
						game_temp[i][j].down = 0;//水滴射出，当前位置清空
						if (game_temp[i + 1][j].num >= 1)
						{
							game_temp[i + 1][j].num += num;
							if(game[i + 1][j].num+num>=8)
							game_temp[i + 1][j].down += game[i + 1][j].num+num-6;
						}
						else
							game_temp[i + 1][j].down += num;
					}
					if (game[i][j].left >= 1)
						//水向左，若左方有且颜色相同，则合并，否则向左喷射
					{
						water_over = 1;
						int num = game[i][j].left;//水滴数量
						game_temp[i][j].left = 0;//水滴射出，当前位置清空
						if (game_temp[i][j - 1].num >= 1)
						{
							game_temp[i][j-1].num += num;
							if (game[i][j-1].num+num >= 8)
								game_temp[i][j-1].left += game[i][j-1].num+num - 6;
						}
						else
							game_temp[i][j - 1].left += num;
					}
					if (game[i][j].right >= 1)
						//水向右，若右方有且颜色相同，则合并，否则向右喷射
					{
						water_over = 1;
						int num = game[i][j].right;//水滴数量
						game_temp[i][j].right = 0;//水滴射出，当前位置清空
						if (game_temp[i][j + 1].num >= 1)
						{
							game_temp[i][j+1].num += num;
							if (game[i][j+1].num+num >= 8)
								game_temp[i][j+1].right += game[i][j+1].num+num - 6;
						}
						else
							game_temp[i][j + 1].right += num;
					}
			}
		}
		game_fuzhi(game_temp, game);
}
void condition_left()//左移一格
{
	for (int i = 1; i <= row; i++)
	{
		for (int j = 2; j <= column; j++)
		{
			if (game[i][j-1].right > 0&& game[i][j].num!=0)//左移水滴与右移运动水合并
			{
				if (game[i][j-1].right + game[i][j].num < 7)
				{
					game[i][j].num += game[i][j-1].right;
					game[i][j-1].right = 0;
				}
				else
				{
					game[i][j-1].right -= game[i][j].num+1;
					game[i][j].num = 5;
				}
			}
			game[i][j-1].num = game[i][j].num;
			
			if (j == column)//水滴左移并边界重添加
			{
				game[i][j].num = 0;
				game[i][j].up = 0;
				game[i][j].down = 0;
				game[i][j].left = 0;
				game[i][j].right = 0;
				num_water_all += 1;
				int p = randombetween(1, 100);
				if (p <= game_random_mode_4[0])
					game[i][j].num = 1;
				else if (p <= game_random_mode_4[0] + game_random_mode_4[1])
					game[i][j].num = 2;
				else if (p <= game_random_mode_4[0] + game_random_mode_4[1] + game_random_mode_4[2])
					game[i][j].num = 3;
				else if (p <= game_random_mode_4[0] + game_random_mode_4[1] + game_random_mode_4[2] + game_random_mode_4[3])
					game[i][j].num = 4;
				else if (p <= game_random_mode_4[0] + game_random_mode_4[1] + game_random_mode_4[2] + game_random_mode_4[3] + game_random_mode_4[4])
					game[i][j].num = 5;
				else
					num_water_all -= 1;
			}
		}
	}
	for (int i = 0; i < row; i++)
	{
		if (game[i][1].num >0)
			HP -= 1;
	}
	if (fight_1 == 1)
	{
		int y = randombetween(1, row);
		game[y][2].right += 7;
	}
}
void condition_left_again(int t,int m)//判定什么时候左移
{
	condition_water_num();
	if (m > 1)
	{
		if (t % m == 0)
			condition_left();//保卫模式的后移 
	}
	else if (m == 1)
	{
		if (t % 3 != 0)
			condition_left();
	}
	else if (m == 0)
		condition_left();
	else if (m <= -1)
	{
		condition_left();
		condition_left_again(t, m + 3);
	}
}
void draw_ice(float x, float y, int row, int column, int n_water)//绘制固定水滴
{
	if (n_water != 0)
	{
		// 设置填充颜色和线条颜色
		setfillcolor(RGB(rgb[rgb_now + 5][0], rgb[rgb_now + 5][1], rgb[rgb_now + 5][2]));
		setlinecolor(RGB(rgb[rgb_now + 5][0], rgb[rgb_now + 5][1], rgb[rgb_now + 5][2]));
		// 根据 n_water 的值绘制不同的圆外部
		if (n_water == 1) {
			// 绘制第一种圆，若干个
			fillcircle(x + 0.1 * distance_half, y + 0.1 * distance_half, 0.3 * distance_half );
			fillcircle(x - 0.6 * distance_half, y - 0.2 * distance_half, 0.11 * distance_half);
			fillcircle(x - 0.3 * distance_half, y + 0.6 * distance_half, 0.13 * distance_half);
		}
		else if (n_water == 2) {
			// 绘制第二种圆，若干个
			fillcircle(x, y, 0.45 * distance_half); // 大圆
			fillcircle(x + 0.5 * distance_half, y + 0.5 * distance_half, 0.23 * distance_half); // 小圆1
		}
		else if (n_water == 3) {
			// 绘制第三种圆，若干个
			fillcircle(x + 0.35 * distance_half, y + 0.3 * distance_half, 0.63 * distance_half);
			fillcircle(x - 0.35 * distance_half, y + 0.1 * distance_half, 0.35 * distance_half);
		}
		else if (n_water == 4) {
			// 绘制第四种圆，若干个
			fillcircle(x, y, 0.79 * distance_half);
		}
		setfillcolor(RGB(rgb[rgb_now][0], rgb[rgb_now][1], rgb[rgb_now][2]));
		// 绘制内部
		if (n_water == 1) {
			// 绘制第一种圆，若干个
			fillcircle(x + 0.1 * distance_half, y + 0.1 * distance_half, 0.25 * distance_half);
			fillcircle(x - 0.6 * distance_half, y - 0.2 * distance_half, 0.08 * distance_half);
			fillcircle(x - 0.3 * distance_half, y + 0.6 * distance_half, 0.1 * distance_half);
		}
		else if (n_water == 2) {
			// 绘制第二种圆，若干个
			fillcircle(x, y, 0.4 * distance_half); // 大圆
			fillcircle(x + 0.5 * distance_half, y + 0.5 * distance_half, 0.2 * distance_half); // 小圆1
		}
		else if (n_water == 3) {
			// 绘制第三种圆，若干个
			fillcircle(x + 0.35 * distance_half, y + 0.3 * distance_half, 0.55 * distance_half);
			fillcircle(x - 0.35 * distance_half, y + 0.1 * distance_half, 0.3 * distance_half);
		}
		else if (n_water == 4) {
			// 绘制第四种圆，若干个
			fillcircle(x, y, 0.7 * distance_half);
		}
	}
}
void draw_water(float x, float y, int row_0, int column_0, int j)//绘制运动水滴
{
	//先统一用绿色
	//将距离平均分为20份，n_water代表两中心点距离份数
	//需要分别对上下左右四个方向进行发射
	//通过行列数组得到四个方向水滴的个数，不为0则绘制
	float y1 = 0, y2 = 0, x1 = 0, x2 = 0;
	int k = rgb_now;
		setfillcolor(RGB(rgb_average[k][0], rgb_average[k][1], rgb_average[k][2]));
		setlinecolor(RGB(rgb_average[k][0], rgb_average[k][1], rgb_average[k][2]));
		float radius;
		float water_time_distance = (j - 5) * distance / 30;
		if (game[row_0][column_0].up != 0)
		{
			radius = (2 * game[row_0][column_0].up + 2) * distance * 0.01;
			if (row_0 > 1)
			{
				y1 = y - distance / 12 * j;
				fillcircle(x, y1, radius + 0.05 * distance_half);
			}
			else if (row_0 == 1 && j <= 5)
			{
				y1 = y - distance / 12 * j;
				fillcircle(x, y1, radius + 0.05 * distance_half);
			}
			else if (row_0 == 1 && j > 5&&row<=16&&column<=16)
			{
				y1 = y - distance_half;
				radius = radius / 3 + 0.02 * distance_half;
				fillcircle(x, y1 + radius + water_time_distance, radius);
				fillcircle(x + water_time_distance, y1 + radius, radius);
				fillcircle(x - water_time_distance, y1 + radius, radius);
				fillcircle(x + water_time_distance * 0.7, y1 + radius + water_time_distance * 0.7, radius);
				fillcircle(x - water_time_distance * 0.7, y1 + radius + water_time_distance * 0.7, radius);
			}
		}
		if (game[row_0][column_0].down != 0)
		{
			radius = (2 * game[row_0][column_0].down + 2) * distance * 0.01;
			if (row_0 < row)
			{
				y2 = y + distance / 12 * j;
				fillcircle(x, y2, radius + 0.05 * distance_half);
			}
			else if (row_0 == row && j <= 5)
			{
				y2 = y + distance / 12 * j;
				fillcircle(x, y2, radius + 0.05 * distance_half);
			}
			else if (row_0 == row && j > 5 && row <= 16 && column <= 16)
			{
				y2 = y + distance_half;
				radius = radius / 3 + 0.02 * distance_half;
				fillcircle(x, y2 - radius - water_time_distance, radius);
				fillcircle(x + water_time_distance, y2 - radius, radius);
				fillcircle(x - water_time_distance, y2 - radius, radius);
				fillcircle(x + water_time_distance * 0.7, y2 - radius - water_time_distance * 0.7, radius);
				fillcircle(x - water_time_distance * 0.7, y2 - radius - water_time_distance * 0.7, radius);
			}
		}
		if (game[row_0][column_0].left!= 0)
		{
			radius = (2 * game[row_0][column_0].left + 2) * distance * 0.01;
			if (column_0 > 1)
			{
				x1 = x - distance / 12 * j;
				fillcircle(x1, y, radius + 0.05 * distance_half);
			}
			else if (column_0 == 1 && j <= 5)
			{
				x1 = x - distance / 12 * j;
				fillcircle(x1, y, radius + 0.05 * distance_half);
			}
			else if (column_0 == 1 && j > 5 && row <= 16 && column <= 16)
			{
				x1 = x - distance_half;
				radius = radius / 3 + 0.02 * distance_half;
				fillcircle(x1 + radius + water_time_distance, y, radius);
				fillcircle(x1 + radius, y + water_time_distance, radius);
				fillcircle(x1 + radius, y - water_time_distance, radius);
				fillcircle(x1 + radius + water_time_distance * 0.7, y + water_time_distance * 0.7, radius);
				fillcircle(x1 + radius + water_time_distance * 0.7, y - water_time_distance * 0.7, radius);
			}
		}
		if (game[row_0][column_0].right!= 0)
		{
			radius = (2 * game[row_0][column_0].right + 2) * distance * 0.01;
			if (column_0 < column)
			{
				x2 = x + distance / 12 * j;
				fillcircle(x2, y, radius + 0.05 * distance_half);
			}
			else if (column_0 == column && j <= 5)
			{
				x2 = x + distance / 12 * j;
				fillcircle(x2, y, radius + 0.05 * distance_half);
			}
			else if (column_0 == column && j > 5 && row <= 16 && column <= 16)
			{
				x2 = x + distance_half;
				radius = radius / 3 + 0.02 * distance_half;
				fillcircle(x2 - radius - water_time_distance, y, radius);
				fillcircle(x2 - radius, y + water_time_distance, radius);
				fillcircle(x2 - radius, y - water_time_distance, radius);
				fillcircle(x2 - radius - water_time_distance * 0.7, y + water_time_distance * 0.7, radius);
				fillcircle(x2 - radius - water_time_distance * 0.7, y - water_time_distance * 0.7, radius);
			}
	}
}
void draw_lines() // 绘制网格线
{
	// 设置线条颜色为天蓝色
	setfillcolor(RGB(135, 206, 250)); // 使用RGB宏设置线条颜色为天蓝色
	setlinecolor(RGB(135, 206, 250)); // 使用RGB宏设置线条颜色为天蓝色
	// 绘制横线
	for (int k = 0; k <= row; k++) { // 修改为 k 从 0 到 row (包括底边线)
		int y =(int) (distance * k + y_0); // 每条线的y坐标是正确的框的边缘
		line(x_0, y, x_0 + column * distance , y); // 绘制每一行横线
	}

	// 绘制竖线
	for (int l = 0; l <= column; l++) { // 修改为 l 从 0 到 column (包括右边线)
		int x = (int)(distance * l + x_0); // 每条线的x坐标是正确的框的边缘
		line(x, y_0, x, y_0 + row * distance); // 绘制每一列竖线
	}
}
void draw_word()//绘制文字
{
	TCHAR s[40];//狂暴模式
	if (water_mode == 1)
	{
		settextcolor(YELLOW);
		swprintf_s(s, _T("经典模式")); // 狂暴模式
		settextstyle(40, 0, _T("宋体")); // 设置文本样式
		outtextxy(0, 5, s);

	}
	else if (water_mode == 2)
	{
		settextcolor(RED);
		swprintf_s(s, _T("炸弹模式")); // 狂暴模式
		settextstyle(40, 0, _T("宋体")); // 设置文本样式
		outtextxy(0, 5, s);
	}
	else if (water_mode == 3)
	{
		settextcolor(BLUE);
		swprintf_s(s, _T("核弹模式")); // 核弹模式
		settextstyle(40, 0, _T("宋体")); // 设置文本样式
		outtextxy(0, 5, s);
	}
	else if (water_mode == 4)
	{
		settextcolor(GREEN);
		swprintf_s(s, _T("保卫模式")); // 保卫模式
		settextstyle(40, 0, _T("宋体")); // 设置文本样式
		outtextxy(0, 5, s);
		swprintf_s(s, _T("HP:%d"),HP); // 保卫模式
		settextstyle(40, 0, _T("宋体")); // 设置文本样式
		outtextxy(0, 45, s);
		settextcolor(YELLOW);
		if (fight_1 == 1||fight_2==1||fight_3==1||fight_4==1)
		{
			swprintf_s(s, _T("强化模式")); // 保卫模式
			settextstyle(40, 0, _T("宋体")); // 设置文本样式
			outtextxy(0, 85, s);
		}
	}
	if (mode_4 == 4)
	{
		settextcolor(GREEN);
		swprintf_s(s, _T("自定义")); // 保卫模式
		settextstyle(40, 0, _T("宋体")); // 设置文本样式
		outtextxy(1174, 5, s);
	}
	else if (mode_4 == 1)
	{
		settextcolor(GREEN);
		swprintf_s(s, _T("简单难度")); 
		settextstyle(40, 0, _T("宋体")); // 设置文本样式
		outtextxy(1140, 5, s);
	}
	else if (mode_4 == 2)
	{
		settextcolor(YELLOW);
		swprintf_s(s, _T("普通难度")); 
		settextstyle(40, 0, _T("宋体")); // 设置文本样式
		outtextxy(1140, 5, s);
	}
	else if (mode_4 == 3)
	{
		settextcolor(RED);
		swprintf_s(s, _T("困难难度")); 
		settextstyle(40, 0, _T("宋体")); // 设置文本样式
		outtextxy(1140, 5, s);
	}
	if (mode_4 != 4)
	{
		if ((score_max[water_mode * 3 + mode_4 - 3] != 0))
		{
			if (water_mode == 4)
			{
				settextcolor(WHITE);
				swprintf_s(s, _T("历史最高 %d"), score_max[water_mode * 3 + mode_4 - 3]); // 
				settextstyle(20, 0, _T("宋体")); // 设置文本样式
				outtextxy(1160, 45, s);
			}
			else
			{
				settextcolor(WHITE);
				swprintf_s(s, _T("历史最高 %d"), score_max[water_mode * 3 + mode_4 - 3]); // 
				settextstyle(20, 0, _T("宋体")); // 设置文本样式
				outtextxy(1160, 45, s);
			}
		}
	}
	setfillcolor(RGB(200, 200, 200));
	setlinecolor(RGB(200, 200, 200));
	fillrectangle(width-82, height-42, width, height);
	settextcolor(RGB(100,100, 100));
	swprintf_s(s, _T("退出")); // 
	settextstyle(40, 0, _T("宋体")); // 设置文本样式
	outtextxy(width-80,height-40, s);

}
void mouse() //检测鼠标左键坐标
{
	time_mouse -= TIME;
	if ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) && time_mouse <= 0) {
		time_mouse = 120;
		// 获取鼠标在屏幕上的位置
		POINT cursorPos;
		GetCursorPos(&cursorPos); // 获取屏幕坐标
		// 获取当前活动窗口的句柄
		HWND hwnd = GetForegroundWindow(); // 获取前景窗口句柄
		RECT windowRect;
		// 获取活动窗口的位置
		if (GetWindowRect(hwnd, &windowRect)) {
			// 计算相对窗口左上角的坐标
			x_mouse = cursorPos.x - windowRect.left; // 获取相对 x 坐标
			y_mouse = cursorPos.y - windowRect.top;  // 获取相对 y 坐标
			// 获取标题栏和边框的高度
			int titleBarHeight = GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CYCAPTION);
			// 减去标题栏和边框的高度
			y_mouse -= titleBarHeight; // 调整 y 坐标
			// 检查坐标是否在窗口客户区内
			if (x_mouse < 0 || y_mouse < 0 ||
				x_mouse >= windowRect.right - windowRect.left ||
				y_mouse >= windowRect.bottom - windowRect.top - titleBarHeight) {
				// 鼠标在窗口外，不进行任何处理
				n_mouse = 0; // 可以选择重置鼠标标记
			}
			else {
				n_mouse = 1; // 标记鼠标位置已获取
			}
		}
	}
}
void mouse_count()//根据鼠标坐标计算各种坐标
{
	if (n_mouse == 1)
	{
		n_mouse = 0;
		x_mouse -= 7;//可能因为窗口左侧或者右侧有些许的空白导致的不知名原因的鼠标位置偏移
		y_mouse -= 2;
		if (game_scene != 3)
		{
			if (game_scene == 0)//自定义界面游玩为100
			{
				mouse_water();
			}
			else if (game_scene == 4)//自定义模式界面结局游戏结算界面1
			{
				mouse_result_100();
			}
		}
		else if(game_scene==3)
		{
			if (scene == 0)//初始界面
			{
				mouse_scene_0();
			}
			else if (scene == 1)//模式1
			{
				mouse_scene_1();
			}
			else if (scene == 2)//
			{
				mouse_scene_2();
			}
			else if (scene == 3)//
			{
				mouse_scene_3();
			}
			else if (scene == 4)//
			{
				mouse_scene_4();
			}
			else if (scene == 5)//
			{
				mouse_scene_5();
			}
			else if (scene == 51)
			{
				mouse_scene_51();
			}
			else if (scene == 52)
			{
				mouse_scene_52();
			}
			else if (scene == 53)
			{
				mouse_scene_53();
			}
		}
	}
}
void mouse_water()//根据鼠标坐标增加水滴
{
	if (currentValue!= 0||water_mode==4)
	{
		for (int k = 1; k <= row; k++)//y
		{
			for (int l = 1; l <= column; l++)//x
			{
				float x = distance * (l - 0.5) + x_0;//中心坐标
				float y = distance * (k - 0.5) + y_0;
				if (game[k][l].num >= 1&& game[k][l].num <= 4) {
					if (x_mouse<x + distance/2 && x_mouse>x - distance/2&& y_mouse<y + distance_half && y_mouse>y - distance_half)
					{
							game[k][l].num += 1;
							num_water_use++;
							currentValue--;//不会影响现在水滴，目的防止水滴为负数
							mouse_late = 1;//防止异常结局
							if (water_mode == 3||fight_2==1)
							{
								game[k][l].num += 8;
								game[k][l].left += 12;
								game[k][l].right += 12;
								game[k][l].up += 12;
								game[k][l].down += 12;
								if(water_mode==3)
								play_time -= 1.5;
							}
							else if (water_mode == 2 || water_mode == 4)
							{
								game[k][l].num += 5;
								game[k][l].left += 4;
								game[k][l].right += 4;
								game[k][l].up += 4;
								game[k][l].down += 4;
								if (water_mode == 2)
									play_time -= 0.5;
							}
					}
				}
			}
		}
	}
	if (x_mouse>= width - 80 && y_mouse >= height - 40)//退出
	{
		game_scene = 3;
		j = 1;
	}
}
void mouse_result_100()//自定义结局
{
	if (x_mouse >= 410 && x_mouse <= 800 && y_mouse >= 440 && y_mouse <= 530)
	{
		j = 1;
		game_scene = 1;//重来
	}
	else if (x_mouse >= 1100 && y_mouse <= 105&&y_mouse >= 64)
	{
		j = 1;
		game_scene =3;//退出
	}
}
void continue_result()//重新开始的结局处理
{
	j = 0;
	if (water_mode == 1)
		time_mouse = 1000;
	else
		time_mouse = 500;
}
void begin()//游戏内初始化总函数
{
	game_scene = 0;
	srand(time(0));//随机数种子
	game_begin();
	input_game();
	cleardevice();
	Sleep(10);
}
void count(int p)//游戏内计算总函数
{
	mouse();
	mouse_count();//鼠标获取与点击判断
	if (p == 0)
	{
		if (water_mode == 4)//保卫模式独有的
		{
			int t = ((int)(play_time * 100)/12);
			int m = 6 - mode_4 - time_r;
			condition_left_again(t, m);//反复判断是否水滴左移
		}
		condition_update();//运动水滴更新
		condition_water_num();//固定水滴更新
		mouse_late = 0;//更新后重置鼠标冷却,避免部分水滴为0后异常结局的情况
	}
	else if (p == 10&&mouse_late ==0)
		game_over();//结局判断
	clock_sleep();//精确延时
}
void play()//游玩过程的通用函数
{
	for (j = 0; j == 0;) 
	{
		begin();//初始化
		for (int p = 0; j == 0; p++)//p为有计时作用的变量
		{
			count(p% 12);//鼠标与计算
			draw(p % 12);//绘制
		}
		if (game_scene == 1)//再来一次
		{
			continue_result();//重新开始的结局处理
			continue;
		}
		break;//运行结束后返回界面1即上级界面
	}
}
void draw(int p)//游玩内绘制总函数
{
	if (water_mode == 1 || p % 2 == 0|| water_mode == 4) {
		BeginBatchDraw();
		setbkcolor(BLACK);
		cleardevice();
		draw_lines();//画网格线
		for (int k = 1; k <= row; k++)//行
		{
			for (int l = 1; l <= column; l++)//列
			{
				float x = distance * (l - 0.5) + x_0;
				float y = distance * (k - 0.5) + y_0;
				draw_ice(x, y, k, l,game[k][l].num);//画固定水
				draw_water(x, y, k, l, p);//画移动水
			}
		}
		draw_word();//画字
		draw_circle();//画水滴数量圆
		circle_time();//画计时圆
		EndBatchDraw();
	}
}
void bug()//超出边界警告
{
	BeginBatchDraw();
	printf("\a");
	setcolor(RED);
	TCHAR s[40]; // 增加字符数组大小
	swprintf_s(s, _T("超出边界！")); // 
	settextstyle(200, 0, _T("宋体")); // 设置文本样式
	outtextxy(width / 2 - 400, height / 2 - 100, s); // 
	setcolor(BLACK);
	EndBatchDraw();
	Sleep(1000);
}
void draw_circle()//绘制显示水滴数量的函数
{
	TCHAR s[40];//狂暴模式
	//
	int cirx = 1100, ciry = 400; // 圆心坐标
	int r = 160; // 圆的半径
	setlinecolor(RGB(55, 178, 54));
	setfillcolor(RGB(55, 178, 54));
	circle(cirx, ciry, r);
	TCHAR v[40]; // 存储展示水滴文字
	if (water_mode == 1) {
		if (currentValue <= 59 && currentValue >= 1)
		{
			float hudu_fill=0;
			float percent = (float)currentValue / 30;
			if (currentValue <= 30) {
				int i = 0;
				for (; i < 105; i++)
				{
					if (math_circle_size[i] <= percent && math_circle_size[i + 1] >= percent)
					{
						hudu_fill=math_circle_hudu[i];
						break;
					}
				}
				float height_h = r * cos(hudu_fill);
				float height_x = fabs(r * sin(hudu_fill));
				line(cirx - height_x, ciry + height_h, cirx + height_x, ciry + height_h); // 画水的高度线
				floodfill(cirx, ciry + r - 1, RGB(55, 178, 54));
			}
			else
			{
				percent-=1;
				int i = 0;
				for (; i < 105; i++)
				{
					if (math_circle_size[i] <= percent && math_circle_size[i + 1] >= percent)
					{
						hudu_fill = math_circle_hudu[i];
						break;
					}
				}
				float height_h = r * cos(hudu_fill);
				float height_x = fabs(r * sin(hudu_fill));
				fillcircle(cirx, ciry, r);
				setlinecolor(GREEN);
				setfillcolor(GREEN);
				circle(cirx, ciry, r);
				line(cirx - height_x, ciry + height_h, cirx + height_x, ciry + height_h); // 画水的高度线
				floodfill(cirx, ciry + r - 1, GREEN);
			}
		}
		else if (currentValue >= 60)
		{
			setlinecolor(GREEN);
			setfillcolor(GREEN);
			fillcircle(cirx, ciry, r);
		}
		settextcolor(RGB(152, 251, 152));
		settextstyle(100, 0, _T("宋体")); // 设置文本样式
		swprintf_s(v, _T("%d"), currentValue); // 格式化水滴数值字符串
		int textWidth = textwidth(v);//计算文本的宽度
		int textHeight = textheight(v);
		outtextxy(cirx - textWidth / 2, ciry - textHeight / 2, v); // 显示水滴数量
	}
	else if (water_mode >=2)
	{
		float hudu_fill=0;
		float percent;
		if (num_water_all >= 1)
			percent = (float)num_water_boom / num_water_all * 2;
		else
			percent = 2;
		if (water_mode == 4)//保卫模式的奖励水滴
		{
			percent = (float)(num_water_boom % (boom_max + 1)) / (boom_max/2);
			if (num_water_boom % (boom_max + 1) >= (boom_max / 2) && k == 0)
			{
				for (int i =1; i <= row; i++)
				{
					game[i][2].right+=4-mode_4;
				}
				game[1][4].right += 2;
				game[row][4].right += 2;
				k = 1;
		    }
			else if (num_water_boom % (boom_max + 1) <(boom_max / 2) && k == 1)
			{
				game[4][2].right += 12-mode_4*2+fight_4*8;
				game[7][2].right += 12-mode_4*2 + fight_4 * 8;
				game[12][2].right += 12-mode_4*2 + fight_4 * 8;
				game[15][2].right += 12-mode_4*2 + fight_4 * 8;
				k = 0;

			}
		   
		}
		if (percent <= 1&&percent>0) {
			int i = 0;
			for (; i < 105; i++)
			{
				if (math_circle_size[i] <= percent && math_circle_size[i + 1] >= percent)
				{
					hudu_fill = math_circle_hudu[i];
					break;
				}
			}
				float height_h = r * cos(hudu_fill);
				float height_x = fabs(r * sin(hudu_fill));
				line(cirx - height_x, ciry + height_h, cirx + height_x, ciry + height_h); // 画水的高度线
				floodfill(cirx, ciry + r - 1, RGB(55, 178, 54));
		}
		else if (percent >= 1)
		{
				percent -= 1;
				int i = 0;
				for (; i < 105; i++)
				{
					if (math_circle_size[i] <= percent && math_circle_size[i + 1] >= percent)
					{
						hudu_fill = math_circle_hudu[i];
						break;
					}
				}
				float height_h = r * cos(hudu_fill);
				float height_x = fabs(r * sin(hudu_fill));
				fillcircle(cirx, ciry, r);
				setlinecolor(GREEN);
				setfillcolor(GREEN);
				circle(cirx, ciry, r);
				line(cirx - height_x, ciry + height_h, cirx + height_x, ciry + height_h); // 画水的高度线
				floodfill(cirx, ciry + r - 1, GREEN);
		}
		settextcolor(RGB(152, 251, 152));
		settextstyle(100, 0, _T("宋体")); // 设置文本样式
		if (water_mode == 4)
			swprintf_s(v, _T("%d"), num_water_boom); // 格式化水滴数值字符串

		else
		swprintf_s(v, _T("%.0f%%"), (float)percent*100); // 格式化水滴数值字符串
		int textWidth = textwidth(v);//计算文本的宽度
		int textHeight = textheight(v);
		outtextxy(cirx - textWidth / 2, ciry - textHeight / 2, v); // 显示水滴数量
	}
	//
}
void circle_time()//绘制计时圆与火力增援
{
	float t = play_time;
	int x = x_0 / 2, y = height / 2, r = 140;
	setfillcolor(RGB(181, 126, 230));
	setlinecolor(RGB(181, 126, 230));
	circle(x, y, r);
	TCHAR s[20]; // 增加字符数组大小
	settextstyle(80, 0, _T("宋体")); // 设置文本样式
	settextcolor(RGB(168, 80, 188));
	if (num_water_boom == 0)
	{
		if (water_mode == 1)
			t = 10;
		else if (water_mode == 2||water_mode==3)
			t = 12;
		else if (water_mode == 4)
			t = 0;
		float hudu = (2 - t / 12 * 2) * 3.14;
		line(x, y, x, y - r);  // 绘制指向12点位置的指针
		line(x, y, x + r * sin(hudu), y - r * cos(hudu));
		floodfill(x - 1, y - r + 1, RGB(181, 126, 230));
		setlinecolor(RGB(168, 80, 188));
		swprintf_s(s, _T("%d"), (int)t);
		int textWidth = textwidth(s); // 计算文本的宽度
		int textHeight = textheight(s); // 计算文本的高度
		outtextxy(x - textWidth / 2, y - textHeight / 2 - 5, s);

	}
	else if (water_mode == 4)
	{
		int k = (int)(play_time * 100) ;//游戏时间，每个单位为10毫秒
		if (k % 1200 == 0)
		{
			time_r += 1;//加速
			int p = k / 1200;
			boom_max += 2 +mode_4*4+ p*(p-1)*(mode_4+1);
			game_random_mode_4[0] += water_mode+1;
			game_random_mode_4[1] += 1;
			game_random_mode_4[2] -= 1;
			game_random_mode_4[3] -= water_mode-1;//密度变化
			game[9][2].right += 13+fight_4*10;
			game[10][2].right += 13+fight_4*10;
			
		}
		float hudu = (2 - t / 12 * 2) * 3.14;
		line(x, y, x, y - r);  // 绘制指向12点位置的指针
		line(x, y, x + r * sin(hudu), y - r * cos(hudu));
		floodfill(x - 1, y - r + 1, RGB(181, 126, 230));
		setlinecolor(RGB(168, 80, 188));
		line(x, y, x, y - r * 2 / 3);
		line(x, y, x + r * sin(hudu) * 0.7, y - r * cos(hudu) * 0.7);
		swprintf_s(s, _T("%.1f"), t);
		int textWidth = textwidth(s); // 计算文本的宽度
		int textHeight = textheight(s); // 计算文本的高度
		outtextxy(x - textWidth / 2, y - textHeight / 2 - 5, s);

	}
	else if (t >= 12)
	{
		fillcircle(x, y, r);
		swprintf_s(s, _T("%d"), (int)play_time);
		int textWidth = textwidth(s); // 计算文本的宽度
		int textHeight = textheight(s); // 计算文本的高度
		outtextxy(x - textWidth / 2, y - textHeight / 2 - 5, s);
	}
	else if(t <= 0.01)
	{
		swprintf_s(s, _T("%d"), 0);
		int textWidth = textwidth(s); // 计算文本的宽度
		int textHeight = textheight(s); // 计算文本的高度
		outtextxy(x - textWidth / 2, y - textHeight / 2 - 5, s);
	}
	else
	{
		float hudu = (2 - t / 12 * 2) * 3.14;
		line(x, y, x, y - r);  // 绘制指向12点位置的指针
		line(x, y, x + r * sin(hudu), y - r * cos(hudu));
		floodfill(x - 1, y - r + 1, RGB(181, 126, 230));
		setlinecolor(RGB(168, 80, 188));
		line(x, y, x, y - r * 2 / 3);
		line(x, y, x + r * sin(hudu) * 0.7, y - r * cos(hudu) * 0.7);
		swprintf_s(s, _T("%.1f"), t);
		int textWidth = textwidth(s); // 计算文本的宽度
		int textHeight = textheight(s); // 计算文本的高度
		outtextxy(x - textWidth / 2, y - textHeight / 2 - 5, s);
	}
}
void game_over()//游戏结束
{
	if (game_scene == 0)
	{
		int o = 0;//判断结局类型
		currentValue = -num_water_use + num_water_begin + num_water_boom;//避免鼠标多次点击偶然出现的水滴数1结局失败的bug
		if (water_mode == 4)
		{
			if (HP <= 0)
			{
				o = 4;
				score_max_update();
			}
		}
		else if (num_water_boom == num_water_all)
		{
			o = 1;
			score_max_update();
		}
		else if (currentValue == 0 && water_over == 0)
			o = 2;
		else if (play_time <= 0&& num_water_boom!=0&&water_mode!=4&&time_open)
			o = 3;
			if (o != 0)
			{
				setfillcolor(BLACK);
				setlinecolor(BLACK);
				fillrectangle(width-100, height-50, width, height);//右下角填黑色
				game_scene = 4;
				j = 0;
				// 定义并计算 "XX!" 文本
					TCHAR s1[40]; // 增加字符数组大小
					settextstyle(300, 0, _T("宋体")); // 设置文本样式
					if (o == 1) {
						settextcolor(GREEN);
						swprintf_s(s1, _T("AC!"));
					}
					else if (o == 2) {
						settextcolor(RED);
						swprintf_s(s1, _T("WA!"));
					}
					else if (o == 3)
					{
						settextcolor(RGB(181, 126, 230));
						swprintf_s(s1, _T("TLE!"));
					}
					else if (o == 4)
					{
						settextcolor(BLUE);
						settextstyle(150, 0, _T("宋体"));
						swprintf_s(s1, _T("得分:%d"), num_water_boom);

					}
				int textWidth1 = textwidth(s1); // 计算文本的宽度
				int textHeight1 = textheight(s1); // 计算文本的高度
				
				outtextxy((width - textWidth1) / 2, height / 2 - textHeight1, s1);

				TCHAR s2[40]; // 增加字符数组大小
				settextstyle(100, 0, _T("宋体")); // 设置文本样式
				if (o == 1||o==4) {
					settextcolor(YELLOW);
					swprintf_s(s2, _T("再来一遍"));
				}
				else if (o == 2 || o == 3) {
					settextcolor(YELLOW);
					swprintf_s(s2, _T("不服再战"));
				}
				int textWidth2 = textwidth(s2); // 计算文本的宽度
				int textHeight2 = textheight(s2); // 计算文本的高度
				outtextxy((width - textWidth2) / 2 - 50, height / 3 * 2 - textHeight2, s2);

				TCHAR s3[40]; // 增加字符数组大小
				settextstyle(50, 0, _T("宋体")); // 设置文本样式
				if (o == 1||o==4) {
					settextcolor(RGB(218,165,32));
					swprintf_s(s3, _T("挑战其它"));
				}
				else if (o == 2 || o == 3) {
					settextcolor(RGB(218, 165, 32));
					swprintf_s(s3, _T("走此小道"));
				}
				int textWidth3 = textwidth(s3); // 计算文本的宽度
				int textHeight3 = textheight(s3); // 计算文本的高度
				// 确保 s3 的中心字符在 x * 3 / 4 处
				outtextxy(width - 200, 60, s3);
				Sleep(200);
				while (j == 0)
				{
					mouse();
					mouse_count();
					Sleep(1);
				}
			}
	}
}
void draw_scene_0()//初始界面绘制
{
	//h1-h5模式的y坐标,h6退出的y坐标,h7音乐的y坐标,h8音效的y坐标
	//x1模式的x坐标,x2退出的x坐标,x3音乐/音效的x坐标
	//gao为矩形高,len1为模式矩形长,len2为退出，音乐/音效矩形长
	int h1 = 170, h2 = 270, h3 = 370, h4 = 470, h5 = 570, h6 = 670, h7 = 570, h8 = 670;//h1-h5模式,h6退出,h7音乐
	int x1 = 400;//各种模式
	int x2 = 50, x3 = 1050;//退出，音乐/音效
	int gao = 80;
	int len1 = 500, len2 = 200;//len1为模式矩形长，len2为退出等矩形长
	BeginBatchDraw();
	setbkcolor(RGB(128, 128, 128));
	cleardevice();
	setfillcolor(WHITE);
	setlinecolor(WHITE);
	fillrectangle(x1, h1, x1 + len1, h1 + gao);//经典
	fillrectangle(x1, h2, x1 + len1, h2 + gao);//炸弹
	fillrectangle(x1, h3, x1 + len1, h3 + gao);//核弹
	fillrectangle(x1, h4, x1 + len1, h4 + gao);//保卫
	fillrectangle(x1, h5, x1 + len1, h5 + gao);//自定义
	fillrectangle(x2, h6, x2 + len2, h6 + gao);//退出
	//fillrectangle(x3, h7, x3 + 100, h7 + gao);//音乐
	//fillrectangle(x3, h8, x3 + 100, h8 + gao);//音效
	//fillrectangle(x3 + 125, h7 + 15, x3 + 175, h7 + 65);//音乐是否
	//fillrectangle(x3 + 125, h8 + 15, x3 + 175, h8 + 65);//音效是否
	settextcolor(BLACK);
	setbkmode(1);
	TCHAR s[40]; // 增加字符数组大小
	settextstyle(50, 0, _T("宋体"));
	settextcolor(BLACK);//黑色
	swprintf_s(s, _T("经典模式"));
	outtextxy(550, 185, s);
	settextcolor(RED);//红色
	swprintf_s(s, _T("炸弹模式"));
	outtextxy(550, 285, s);
	settextcolor(BLUE);//蓝色
	swprintf_s(s, _T("核弹模式"));
	outtextxy(550, 385, s);
	settextcolor(GREEN);//绿色
	swprintf_s(s, _T("保卫模式"));
	outtextxy(550, 485, s);
	settextcolor(BLACK);//黑色
	swprintf_s(s, _T("自定义模式"));
	outtextxy(525, 585, s);
	swprintf_s(s, _T("退出"));
	outtextxy(100, 685, s);
	settextcolor(RGB(255, 205, 0));//黄色
	/*swprintf_s(s, _T("音乐"));
	outtextxy(1050, 585, s);
	swprintf_s(s, _T("音效"));
	outtextxy(1050, 685, s);
	if(x_mouse>=1175 && x_mouse<=1225 && y_mouse>=585 && y_mouse<=665)
		swprintf_s(s, _T("√"));
	else
		swprintf_s(s, _T("关"));
	outtextxy(1175,585,s);
	if(x_mouse>=1175 && x_mouse<=1225 && y_mouse>=685 && y_mouse<=765)
		swprintf_s(s, _T("√"));
	else
		swprintf_s(s, _T("关"));
	outtextxy(1175,685,s);
	*/
	settextcolor(GREEN);
	settextstyle(100, 0, _T("宋体"));
	swprintf_s(s, _T("十滴水plus"));
	int text_width = textwidth(s);
	outtextxy(650 - text_width / 2, 25, s);
	EndBatchDraw();

}
void mouse_scene_0()//初始界面鼠标设置
{
	//h1-h5模式的y坐标,h6退出的y坐标,h7音乐的y坐标,h8音效的y坐标
	//x1模式的x坐标,x2退出的x坐标,x3音乐/音效的x坐标
	//gao为矩形高,len1为模式矩形长,len2为退出，音乐/音效矩形长
	row_column_random = 0;//取消随机设定
	Sleep(100);
	int h1 = 170, h2 = 270, h3 = 370, h4 = 470, h5 = 570, h6 = 670, h7 = 570, h8 = 670;//h1-h5模式,h6退出,h7音乐
	int x1 = 400;//各种模式
	int x2 = 50, x3 = 1050;//退出，音乐/音效
	int gao = 80;
	int len1 = 500, len2 = 200;//len1为模式矩形长，len2为退出等矩形长
	if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h1 && y_mouse <= h1 + gao)//經典模式
	{
		water_mode = 1;
		scene = 1;
		time_open = 1;
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h2 && y_mouse <= h2 + gao)//炸彈模式
	{
		water_mode = 2;
		scene = 2;
		time_open = 1;
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h3 && y_mouse <= h3 + gao)//核彈模式
	{
		water_mode = 3;
		scene = 3;
		time_open = 1;
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h4 && y_mouse <= h4 + gao)//保衛模式
	{
		water_mode = 4;
		row = 18;
		column = 23;
		scene = 4;
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h5 && y_mouse <= h5 + gao)//自定義模式
	{
		scene = 5;

	}
	else if (x_mouse >= x2 && x_mouse <= x2 + len2 && y_mouse >= h6 && y_mouse <= h6 + gao)//退出
	{
		exit(0);
	}
	/*else if (x_mouse >= x3 && x_mouse <= x3 + 100 && y_mouse >= h5 && y_mouse <= h7 + gao)//音樂
	{

	}
	else if (x_mouse >= x3 && x_mouse <= x3 + 100 && y_mouse >= h6 && y_mouse <= h8 + gao)//音效
	{

	}
	*/
}
void draw_scene_1()//第1模式绘制
{
	int h = 150;
	int  gao = 100;
	int x1 = 350;
	int x2 = 200, x3 = 700;
	int len1 = 600, len2 = 400;
	int num1 = 10, num2 = 10, num3 = 10;//简单，普通，困难的最高轮数
	BeginBatchDraw();
	setbkcolor(RGB(128, 128, 128));
	cleardevice();
	setfillcolor(RGB(200, 200, 200));
	setlinecolor(RGB(200, 200, 200));
	fillrectangle(x3, h + 450, x3 + len2, h + gao + 450);//max
	setfillcolor(WHITE);
	setlinecolor(WHITE);
	fillrectangle(x1, h, x1 + len1, h + gao);//简单
	fillrectangle(x1, h + 150, x1 + len1, h + gao + 150);//普通
	fillrectangle(x1, h + 300, x1 + len1, h + gao + 300);//困难
	fillrectangle(x2, h + 450, x2 + len2, h + gao + 450);//重置
	settextcolor(BLACK);
	setbkmode(1);
	TCHAR s[40]; // 增加字符数组大小
	settextstyle(60, 0, _T("宋体"));
	swprintf_s(s, _T("简单"));
	outtextxy(x1 + 240, h + 20, s);//590,170
	swprintf_s(s, _T("普通"));
	outtextxy(x1 + 240, h + 170, s);//590,320
	swprintf_s(s, _T("困难"));
	outtextxy(x1 + 240, h + 320, s);//590,470
	swprintf_s(s, _T("退出"));
	outtextxy(x2 + 140, h + 470, s);//340,620
	settextstyle(25, 0, _T("宋体"));
	swprintf_s(s, _T("简单难度最高剩余水滴:%3d 滴"), score_max[1]);
	outtextxy(x3 + 35, h + 456, s);
	swprintf_s(s, _T("普通难度最高剩余水滴:%3d 滴"), score_max[2]);
	outtextxy(x3 + 35, h + 487, s);
	swprintf_s(s, _T("困难难度最高剩余水滴:%3d 滴"), score_max[3]);
	outtextxy(x3 + 35, h + 518, s);//775,668
	settextcolor(YELLOW);
	settextstyle(100, 0, _T("宋体"));
	swprintf_s(s, _T("难度选择"));
	outtextxy(450, 25, s);
	EndBatchDraw();
}
void mouse_scene_1()//第1模式鼠标
{
	row_column_random = 1;
	Sleep(100);
	int h = 150;
	int gao = 100;
	int x1 = 350;
	int x2 = 200, x3 = 700;
	int len1 = 600, len2 = 400;
	if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h && y_mouse <= h + gao)//簡單
	{
		mode_4 = 1;
		column_min=row_min = 3;
		column_max=row_max = 10;
		num_water_I_begin = 10;
		game_random[0] = 15;
		game_random[1] = 15;
		game_random[2] = 10;
		game_random[3] = 8;
		game_random[4] = 0;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h + 150 && y_mouse <= h + gao + 150)//普通
	{
		mode_4 = 2;
		column_min = row_min = 6;
		column_max = row_max = 12;
		num_water_I_begin = 10;
		game_random[0] = 20;
		game_random[1] = 15;
		game_random[2] = 8;
		game_random[3] = 6;
		game_random[4] = 0;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= gao + 300 && y_mouse <= h + gao + 300)//困難
	{
		mode_4 = 3;
		column_min = row_min = 8;
		column_max = row_max = 15;
		num_water_I_begin = 10;
		game_random[0] = 25;
		game_random[1] = 15;
		game_random[2] = 6;
		game_random[3] = 4;
		game_random[4] = 0;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x2 && x_mouse <= x2 + len2 && y_mouse >= h + 450 && y_mouse <= h + gao + 450)//退出
	{
		water_mode = 1;
		scene = 0;
		Sleep(100);
	}
}
void draw_scene_2()//第2模式绘制
{
	int h = 150;
	int  gao = 100;
	int x1 = 350;
	int x2 = 200, x3 = 700;
	int len1 = 600, len2 = 400;
	int num1 = 10, num2 = 10, num3 = 10;//简单，普通，困难的最高轮数
	BeginBatchDraw();
	setbkcolor(RGB(128, 128, 128));
	cleardevice();
	setfillcolor(RGB(200, 200, 200));
	setlinecolor(RGB(200, 200, 200));
	fillrectangle(x3, h + 450, x3 + len2, h + gao + 450);//max
	setfillcolor(WHITE);
	setlinecolor(WHITE);
	fillrectangle(x1, h, x1 + len1, h + gao);//简单
	fillrectangle(x1, h + 150, x1 + len1, h + gao + 150);//普通
	fillrectangle(x1, h + 300, x1 + len1, h + gao + 300);//困难
	fillrectangle(x2, h + 450, x2 + len2, h + gao + 450);//重置
	settextcolor(BLACK);
	setbkmode(1);
	TCHAR s[40]; // 增加字符数组大小
	settextstyle(60, 0, _T("宋体"));
	swprintf_s(s, _T("简单"));
	outtextxy(x1 + 240, h + 20, s);//590,170
	swprintf_s(s, _T("普通"));
	outtextxy(x1 + 240, h + 170, s);//590,320
	swprintf_s(s, _T("困难"));
	outtextxy(x1 + 240, h + 320, s);//590,470
	swprintf_s(s, _T("退出"));
	outtextxy(x2 + 140, h + 470, s);//340,620
	settextstyle(25, 0, _T("宋体"));
	swprintf_s(s, _T("简单难度最高剩余时间：%.2f秒"), (float)score_max[4] / 100);
	outtextxy(x3 + 35, h + 456, s);//775,606
	swprintf_s(s, _T("普通难度最高剩余时间：%.2f秒"), (float)score_max[5] / 100);
	outtextxy(x3 + 35, h + 487, s);//775,637
	swprintf_s(s, _T("困难难度最高剩余时间：%.2f秒"), (float)score_max[6] / 100);
	outtextxy(x3 + 35, h + 518, s);//775,668
	settextcolor(YELLOW);
	settextstyle(100, 0, _T("宋体"));
	swprintf_s(s, _T("难度选择"));
	outtextxy(450, 25, s);
	EndBatchDraw();
}
void mouse_scene_2()//第2模式鼠标
{
	row_column_random = 1;
	Sleep(100);
	int h = 150;
	int gao = 100;
	int x1 = 350;
	int x2 = 200, x3 = 700;
	int len1 = 600, len2 = 400;
	if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h && y_mouse <= h + gao)//簡單
	{
		mode_4 = 1;
		column_min = row_min = 15;
		column_max = row_max = 24;
		num_water_I_begin = 10;
		game_random[0] = 20;
		game_random[1] = 10;
		game_random[2] = 10;
		game_random[3] = 6;
		game_random[4] = 0;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h + 150 && y_mouse <= h + gao + 150)//普通
	{
		mode_4 = 2;
		column_min = row_min = 18;
		column_max = row_max = 27;
		num_water_I_begin = 10;
		game_random[0] = 30;
		game_random[1] = 10;
		game_random[2] = 7;
		game_random[3] = 4;
		game_random[4] = 0;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= gao + 300 && y_mouse <= h + gao + 300)//困難
	{
		mode_4 = 3;
		column_min = row_min = 21;
		column_max = row_max = 30;
		num_water_I_begin = 10;
		game_random[0] = 40;
		game_random[1] = 10;
		game_random[2] = 4;
		game_random[3] = 2;
		game_random[4] = 0;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x2 && x_mouse <= x2 + len2 && y_mouse >= h + 450 && y_mouse <= h + gao + 450)//退出
	{
		scene = 0;
		Sleep(100);
	}
}
void draw_scene_3()//第3模式绘制
{
	int h = 150;
	int  gao = 100;
	int x1 = 350;
	int x2 = 200, x3 = 700;
	int len1 = 600, len2 = 400;
	int num1 = 10, num2 = 10, num3 = 10;//简单，普通，困难的最高轮数
	BeginBatchDraw();
	setbkcolor(RGB(128, 128, 128));
	cleardevice();
	setfillcolor(RGB(200, 200, 200));
	setlinecolor(RGB(200, 200, 200));
	fillrectangle(x3, h + 450, x3 + len2, h + gao + 450);//max
	setfillcolor(WHITE);
	setlinecolor(WHITE);
	fillrectangle(x1, h, x1 + len1, h + gao);//简单
	fillrectangle(x1, h + 150, x1 + len1, h + gao + 150);//普通
	fillrectangle(x1, h + 300, x1 + len1, h + gao + 300);//困难
	fillrectangle(x2, h + 450, x2 + len2, h + gao + 450);//重置
	settextcolor(BLACK);
	setbkmode(1);
	TCHAR s[40]; // 增加字符数组大小
	settextstyle(60, 0, _T("宋体"));
	swprintf_s(s, _T("简单"));
	outtextxy(x1 + 240, h + 20, s);//590,170
	swprintf_s(s, _T("普通"));
	outtextxy(x1 + 240, h + 170, s);//590,320
	swprintf_s(s, _T("困难"));
	outtextxy(x1 + 240, h + 320, s);//590,470
	swprintf_s(s, _T("退出"));
	outtextxy(x2 + 140, h + 470, s);//340,620
	settextstyle(25, 0, _T("宋体"));
	swprintf_s(s, _T("简单难度最高剩余时间：%.2f秒"), (float)score_max[7]/100);
	outtextxy(x3 + 35, h + 456, s);//775,606
	swprintf_s(s, _T("普通难度最高剩余时间：%.2f秒"), (float)score_max[8]/100);
	outtextxy(x3 + 35, h + 487, s);//775,637
	swprintf_s(s, _T("困难难度最高剩余时间：%.2f秒"), (float)score_max[9]/100);
	outtextxy(x3 + 35, h + 518, s);//775,668
	settextcolor(YELLOW);
	settextstyle(100, 0, _T("宋体"));
	swprintf_s(s, _T("难度选择"));
	outtextxy(450, 25, s);
	EndBatchDraw();
}
void mouse_scene_3()//第3模式鼠标
{
	row_column_random = 1;
	Sleep(100);
	int h = 150;
	int gao = 100;
	int x1 = 350;
	int x2 = 200, x3 = 700;
	int len1 = 600, len2 = 400;
	if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h && y_mouse <= h + gao)//簡單
	{
		mode_4 = 1;
		column_min = row_min = 20;
		column_max = row_max = 28;
		num_water_I_begin = 10;
		game_random[0] = 20;
		game_random[1] = 13;
		game_random[2] = 10;
		game_random[3] = 4;
		game_random[4] = 0;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h + 150 && y_mouse <= h + gao + 150)//普通
	{
		mode_4 = 2;
		column_min = row_min = 25;
		column_max = row_max = 33;
		num_water_I_begin = 10;
		game_random[0] = 35;
		game_random[1] = 20;
		game_random[2] = 8;
		game_random[3] = 4;
		game_random[4] = 0;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= gao + 300 && y_mouse <= h + gao + 300)//困難
	{
		mode_4 = 3;
		column_min = row_min = 30;
		column_max = row_max = 40;
		num_water_I_begin = 10;
		game_random[0] = 30;
		game_random[1] = 18;
		game_random[2] = 6;
		game_random[3] = 2;
		game_random[4] = 0;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x2 && x_mouse <= x2 + len2 && y_mouse >= h + 450 && y_mouse <= h + gao + 450)//退出
	{
		scene = 0;
		Sleep(100);
	}
}
void draw_scene_4()//第4模式绘制
{
	//h为第一个矩形的y坐标,之后每个矩形y坐标都为前一个+150
   //gao为矩形高,len1为模式矩形长,len2为退出等矩形长
   //x1难度的x坐标,x2重置的x坐标,x3最高轮数的x坐标
   //num1-num3为简单，普通，困难的最高轮数
	int h = 150;
	int  gao = 100;
	int x1 = 350;
	int x2 = 200, x3 = 700;
	int x5 = 1020, x6 = 1090;
	int len1 = 600, len2 = 400,len3=50;
	int num1 = 10, num2 = 10, num3 = 10;//简单，普通，困难的最高轮数
	BeginBatchDraw();
	setbkcolor(RGB(128, 128, 128));
	cleardevice();
	setfillcolor(RGB(200, 200, 200));
	setlinecolor(RGB(200, 200, 200));
	fillrectangle(x3, h + 450, x3 + len2, h + gao + 450);//max
	setfillcolor(WHITE);
	setlinecolor(WHITE);
	fillrectangle(x1, h, x1 + len1, h + gao);//简单
	fillrectangle(x1, h + 150, x1 + len1, h + gao + 150);//普通
	fillrectangle(x1, h + 300, x1 + len1, h + gao + 300);//困难
	fillrectangle(x2, h + 450, x2 + len2, h + gao + 450);//返回
	fillrectangle(x5, h + 50, x5 + len3, h + gao);//火力支援-开
	fillrectangle(x6, h + 50, x6 + len3, h + gao);//火力支援-关
	fillrectangle(x5, h + 200, x5 + len3, h + gao + 150);//核弹出击-开
	fillrectangle(x6, h + 200, x6 + len3, h + gao + 150);//核弹出击-关
	fillrectangle(x5, h + 350, x5 + len3, h + gao + 300);//坚不可摧-开
	fillrectangle(x6, h + 350, x6 + len3, h + gao + 300);//坚不可摧-关
	fillrectangle(x5, h -60 , x5 + len3, h + gao-110 );//坚不可摧-开
	fillrectangle(x6, h -60, x6 + len3, h + gao-110);//坚不可摧-关
	settextcolor(BLACK);
	setbkmode(1);
	TCHAR s[40]; // 增加字符数组大小
	settextstyle(60, 0, _T("宋体"));
	swprintf_s(s, _T("简单"));
	outtextxy(x1 + 240, h + 20, s);//590,170
	swprintf_s(s, _T("普通"));
	outtextxy(x1 + 240, h + 170, s);//590,320
	swprintf_s(s, _T("困难"));
	outtextxy(x1 + 240, h + 320, s);//590,470
	swprintf_s(s, _T("退出"));
	outtextxy(x2 + 140, h + 470, s);//340,620
	settextstyle(25, 0, _T("宋体"));
	swprintf_s(s, _T("简单难度最高得分：%5d"), score_max[10]);
	outtextxy(x3 + 35, h + 456, s);//775,606
	swprintf_s(s, _T("普通难度最高得分：%5d"), score_max[11]);
	outtextxy(x3 + 35, h + 487, s);//775,637
	swprintf_s(s, _T("困难难度最高得分：%5d"), score_max[12]);
	outtextxy(x3 + 35, h + 518, s);//775,668
	settextcolor(YELLOW);
	settextstyle(100, 0, _T("宋体"));
	swprintf_s(s, _T("难度选择"));
	outtextxy(450, 25, s);
	settextstyle(40, 0, _T("宋体"));
	if (fight_1 == 0)
		settextcolor(BLACK);
	else
		settextcolor(RED);
	swprintf_s(s, _T("开"));//火力支援-开
	outtextxy(x5 + 5, h + 55, s);//
	if (fight_1 == 1)
		settextcolor(BLACK);
	else
		settextcolor(RED);
	swprintf_s(s, _T("关"));//火力支援-关
	outtextxy(x6 + 5, h + 55, s);//
	if (fight_2 == 0)
		settextcolor(BLACK);
	else
		settextcolor(RED);
	swprintf_s(s, _T("开"));//核弹出击-开
	outtextxy(x5 + 5, h + 205, s);//
	if (fight_2 == 1)
		settextcolor(BLACK);
	else
		settextcolor(RED);
	swprintf_s(s, _T("关"));//核弹出击-关
	outtextxy(x6 + 5, h + 205, s);//
	if (fight_3 == 0)
		settextcolor(BLACK);
	else
		settextcolor(RED);
	swprintf_s(s, _T("开"));//坚不可摧-开
	outtextxy(x5 + 5, h + 355, s);//
	if (fight_3 == 1)
		settextcolor(BLACK);
	else
		settextcolor(RED);
	swprintf_s(s, _T("关"));//坚不可摧-关
	outtextxy(x6 + 5, h + 355, s);//
	if (fight_4 == 0)
		settextcolor(BLACK);
	else
		settextcolor(RED);
	swprintf_s(s, _T("开"));//闪电战-开
	outtextxy(x5 + 5, h -55, s);//
	if (fight_4== 1)
		settextcolor(BLACK);
	else
		settextcolor(RED);
	swprintf_s(s, _T("关"));//闪电战-关
	outtextxy(x6 + 5, h-55, s);//
	settextcolor(RED);
	swprintf_s(s, _T("火力支援"));
	outtextxy(1000, h, s);//1000，150
	swprintf_s(s, _T("核弹出击"));
	outtextxy(1000, h + 150, s);//1000，300
	swprintf_s(s, _T("坚不可摧"));
	outtextxy(1000, h + 300, s);//1000，450
	settextcolor(YELLOW);
	swprintf_s(s, _T("闪电战"));
	outtextxy(1020, h - 105, s);
	EndBatchDraw();
}
void mouse_scene_4()//第4模式鼠标
{
	//h为第一个矩形的y坐标,之后每个矩形y坐标都为前一个+150
//gao为矩形高,len1为模式矩形长,len2为退出等矩形长
//x1难度的x坐标,x2重置的x坐标,x3最高轮数的x坐标
//num1-num3为简单，普通，困难的最高轮数
	int h = 150;
	int  gao = 100;
	int x1 = 350;
	int x2 = 200, x3 = 700;
	int x5 = 1020, x6 = 1090;
	int len1 = 600, len2 = 400, len3 = 50;
	int num1 = 10, num2 = 10, num3 = 10;//简单，普通，困难的最高轮数
	Sleep(100);
	if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h && y_mouse <= h + gao)//簡單
	{
		mode_4 = 1;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h + 150 && y_mouse <= h + gao + 150)//普通
	{
		mode_4 = 2;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= gao + 300 && y_mouse <= h + gao + 300)//困難
	{
		mode_4 = 3;
		game_scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x2 && x_mouse <= x2 + len2 && y_mouse >= h + 450 && y_mouse <= h + gao + 450)//退出
	{
		water_mode = 1;
		scene = 0;
		Sleep(100);
	}
	else if (x_mouse >= x5 && x_mouse <= x5 + len3 && y_mouse >= h + 50 && y_mouse <= h + gao + 100)//火力支援-开
	{
		if (fight_1 == 0)
			fight_1 = 1;
	}
	else if (x_mouse >= x6 && x_mouse <= x6 + len3 && y_mouse >= h + 50 && y_mouse <= h + gao + 100)//火力支援-关
	{
		if (fight_1 == 1)
			fight_1 = 0;
	}
	else if (x_mouse >= x5 && x_mouse <= x5 + len3 && y_mouse >= h + 200 && y_mouse <= h + gao + 250)//核弹出击-开
	{
		if (fight_2 == 0)
			fight_2 = 1;
	}
	else if (x_mouse >= x6 && x_mouse <= x6 + len3 && y_mouse >= h + 200 && y_mouse <= h + gao + 250)//核弹出击-关
	{
		if (fight_2 == 1)
			fight_2 = 0;
	}
	else if (x_mouse >= x5 && x_mouse <= x5 + len3 && y_mouse >= h + 350 && y_mouse <= h + gao + 400)//坚不可摧
	{
		if (fight_3 == 0)
			fight_3= 1;
	}
	else if (x_mouse >= x6 && x_mouse <= x6 + len3 && y_mouse >= h + 350 && y_mouse <= h + gao + 400)
	{
		if (fight_3 == 1)
			fight_3 = 0;
	}
	else if (x_mouse >= x5 && x_mouse <= x5 + len3 && y_mouse >= h - 60 && y_mouse <= h + gao - 110)//闪电战
	{
		
		if (fight_4 == 0)
			fight_4 = 1;
	}
	else if (x_mouse >= x6 && x_mouse <= x6 + len3 && y_mouse >= h - 60 && y_mouse <= h + gao - 110)//
	{
		
		if (fight_4 == 1)
			fight_4 = 0;
	}
	//保卫模式的外挂，1为火力支援，2为核弹打击，3为坚不可摧,4为闪电战
}
void draw_scene_5()//第5模式绘制
{
	/*h1-h3为方格、密度、效果设置的y坐标,h4为返回/确认的y坐标
	gao为矩形高,len1为方格、密度、效果设置矩形长,len2为返回/确认的矩形长
	x1为方格、密度、效果设置的x坐标,x2为返回的x坐标,x3为确认的x坐标
	*/
	int h1 = 200, h2 = 330, h3 = 460, h4 = 600;
	int gao = 80;
	int x1 = 400;
	int x2 = 200, x3 = 700;
	int len1 = 500, len2 = 400;
	BeginBatchDraw();
	setbkcolor(RGB(128, 128, 128));
	cleardevice();
	setfillcolor(WHITE);
	setlinecolor(WHITE);
	fillrectangle(x1, h1, x1 + len1, h1 + gao);//方格设置
	fillrectangle(x1, h2, x1 + len1, h2 + gao);//密度设置
	fillrectangle(x1, h3, x1 + len1, h3 + gao);//效果设置
	fillrectangle(x2, h4, x2 + len2, h4 + 100);//返回
	fillrectangle(x3, h4, x3 + len2, h4 + 100);//确认
	settextcolor(BLACK);
	setbkmode(1);
	TCHAR s[40]; // 增加字符数组大小
	settextcolor(YELLOW);
	swprintf_s(s, _T("自定义模式"));//自定义
	settextstyle(100, 0, _T("宋体"));
	outtextxy(400, 25, s);
	//具体内容
	settextcolor(BLACK);
	settextstyle(50, 0, _T("宋体"));
	swprintf_s(s, _T("方格设置"));
	outtextxy(x1 + 150, h1 + 15, s);
	swprintf_s(s, _T("密度设置"));
	outtextxy(x1 + 150, h2 + 15, s);
	swprintf_s(s, _T("效果设置"));
	outtextxy(x1 + 150, h3 + 15, s);
	settextstyle(80, 0, _T("宋体"));
	swprintf_s(s, _T("返回"));
	outtextxy(x2 + 120, h4 + 10, s);
	swprintf_s(s, _T("确认"));
	outtextxy(x3 + 120, h4 + 10, s);
	EndBatchDraw();
}
void mouse_scene_5()//第5模式鼠标
{
	mode_4 = 4;
	/*h1-h3为方格、密度、效果设置的y坐标,h4为返回/确认的y坐标
	gao为矩形高,len1为方格、密度、效果设置矩形长,len2为返回/确认的矩形长
	x1为方格、密度、效果设置的x坐标,x2为返回的x坐标,x3为确认的x坐标
	*/
	Sleep(100);
	int h1 = 200, h2 = 330, h3 = 460, h4 = 600;
	int gao = 80;
	int x1 = 400;
	int x2 = 200, x3 = 700;
	int len1 = 500, len2 = 400;
	if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h1 && y_mouse <= h1 + gao)//方格设置
	{
		scene = 52;

	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h2 && y_mouse <= h2 + gao)//密度设置
	{
		scene = 51;

	}
	else if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h3 && y_mouse <= h3 + gao)//效果设置
	{
		scene = 53;

	}
	else if (x_mouse >= x2 && x_mouse <= x2 + len2 && y_mouse >= h4 && y_mouse <= h4 + 100)//返回
	{
		scene = 0;

	}
	else if (x_mouse >= x3 && x_mouse <= x3 + len2 && y_mouse >= h4 && y_mouse <= h4 + 100)//确认
	{
		game_scene = 0;

	}
}
void draw_scene_51()//第5模式第1界面密度设置绘制
{
	/*h1-h4为一至四滴概率设置的y坐标,h5为密度设置的y坐标,h6为重置/确认的y坐标
   gao为矩形高,len1为长矩形长,len2为密集等短距形长
   x1为水滴概率的x坐标,x2-x4为密集等短距形的x坐标,x5为重置,x6为确认x坐标,x7,x8为+,-的x坐标
   num1-num4为四个水滴概率
   */
	int h1 = 150, h2 = 250, h3 = 350, h4 = 450, h5 = 550, h6 = 650;
	int gao = 70;//高度，间距为30
	int len1 = 400, len2 = 150;//len1为长矩形长，len2为密集等短距形长
	int x1 = 350;//行、列、水
	int x2 = 540, x3 = 720, x4 = 900;//密集等短距形
	int x5 = 200, x6 = 700;//重置/确认
	int x7 = 800, x8 = 900;//+ -
	int num1 = 1, num2 = 20, num3 = 30, num4 = 40;//四个概率
	BeginBatchDraw();
	setbkcolor(RGB(128, 128, 128));
	cleardevice();
	setfillcolor(WHITE);
	setlinecolor(WHITE);
	fillrectangle(0, 0, width, 100);//水滴密度
	fillrectangle(x1, h1, x1 + len1, h1 + gao);//一滴概率
	fillrectangle(x1, h2, x1 + len1, h2 + gao);//两滴概率
	fillrectangle(x1, h3, x1 + len1, h3 + gao);//三滴概率
	fillrectangle(x1, h4, x1 + len1, h4 + gao);//四滴概率
	fillrectangle(x2, h5, x2 + len2, h5 + gao);//密集
	fillrectangle(x3, h5, x3 + len2, h5 + gao);//一般
	fillrectangle(x4, h5, x4 + len2, h5 + gao);//普通
	fillrectangle(x5, h6, x5 + len1, h6 + gao);//重置
	fillrectangle(x6, h6, x6 + len1, h6 + gao);//确认
	fillrectangle(x7, h1, x7 + gao, h1 + gao);//一滴概率+
	fillrectangle(x8, h1, x8 + gao, h1 + gao);//一滴概率-
	fillrectangle(x7, h2, x7 + gao, h2 + gao);//两滴概率+
	fillrectangle(x8, h2, x8 + gao, h2 + gao);//两滴概率-
	fillrectangle(x7, h3, x7 + gao, h3 + gao);//三滴概率+
	fillrectangle(x8, h3, x8 + gao, h3 + gao);//三滴概率-
	fillrectangle(x7, h4, x7 + gao, h4 + gao);//四滴概率+
	fillrectangle(x8, h4, x8 + gao, h4 + gao);//四滴概率-
	settextcolor(BLACK);
	setbkmode(1);
	TCHAR s[40]; // 增加字符数组大小
	settextcolor(BLACK);
	swprintf_s(s, _T("水滴密度"));//水滴密度
	settextstyle(100, 0, _T("宋体"));
	outtextxy(450, 0, s);
	//设置内容
	settextstyle(50, 0, _T("宋体"));
	swprintf_s(s, _T("一滴概率：%2d%%"), game_random[0]);//一滴概率
	outtextxy(x1 + 30, h1 + 10, s);//380,160
	swprintf_s(s, _T("+"));//一滴概率+
	outtextxy(x7 + 22, h1 + 10, s);//822,160
	swprintf_s(s, _T("-"));//一滴概率-
	outtextxy(x8 + 22, h1 + 10, s);//922,160
	swprintf_s(s, _T("两滴概率：%2d%%"), game_random[1]);//两滴概率
	outtextxy(x1 + 30, h2 + 10, s);//380,260
	swprintf_s(s, _T("+"));//两滴概率+
	outtextxy(x7 + 22, h2 + 10, s);//822,260
	swprintf_s(s, _T("-"));//两滴概率-
	outtextxy(x8 + 22, h2 + 10, s);//922,260
	swprintf_s(s, _T("三滴概率：%2d%%"), game_random[2]);//三滴概率
	outtextxy(x1 + 30, h3 + 10, s);//380,360
	swprintf_s(s, _T("+"));//三滴概率+
	outtextxy(x7 + 22, h3 + 10, s);//822,360
	swprintf_s(s, _T("-"));//三滴概率-
	outtextxy(x8 + 22, h3 + 10, s);//922,360
	swprintf_s(s, _T("四滴概率：%2d%%"), game_random[3]);//四滴概率
	outtextxy(x1 + 30, h4 + 10, s);//380,460
	swprintf_s(s, _T("+"));//四滴概率+
	outtextxy(x7 + 22, h4 + 10, s);//822,460
	swprintf_s(s, _T("-"));//四滴概率-
	outtextxy(x8 + 22, h4 + 10, s);//922,460
	swprintf_s(s, _T("密集"));//密集
	outtextxy(x2 + 25, h5 + 10, s);//565,560
	swprintf_s(s, _T("普通"));
	outtextxy(x3 + 25, h5 + 10, s);//745,560
	swprintf_s(s, _T("稀疏"));
	outtextxy(x4 + 25, h5 + 10, s);//925,560
	swprintf_s(s, _T("重置"));//重置
	outtextxy(x5 + 150, h6 + 10, s);//350,660
	swprintf_s(s, _T("确认"));//确认
	outtextxy(x6 + 150, h6 + 10, s);//850,660
	settextcolor(YELLOW);
	swprintf_s(s, _T("一键设置"));//一键设置
	outtextxy(x1 - 50, h5 + 10, s);//300,560
	EndBatchDraw();
}
void mouse_scene_51()//第5模式第1界面密度设置鼠标
{
	/*h1-h4为一至四滴概率设置的y坐标,h5为密度设置的y坐标,h6为重置/确认的y坐标
   gao为矩形高,len1为长矩形长,len2为密集等短距形长
   x1为水滴概率的x坐标,x2-x4为密集等短距形的x坐标,x5为重置,x6为确认x坐标,x7,x8为+,-的x坐标
   num1-num4为四个水滴概率
   */
	Sleep(100);
	int h1 = 150, h2 = 250, h3 = 350, h4 = 450, h5 = 550, h6 = 650;
	int gao = 70;//高度，间距为30矩形高度
	int len1 = 400, len2 = 150;//len1为长矩形长，len2为密集等短距形长
	int x1 = 350;//橫坐標起始位置
	int x2 = 540, x3 = 720, x4 = 900;//密集等短距形
	int x5 = 200, x6 = 700;//重置/确认
	int x7 = 800, x8 = 900;//+ -
	if (x_mouse >= x2  && x_mouse <= x2 + len2  && y_mouse >= h5 && y_mouse <= h5 + gao)
	{
		game_random[0] = 15;
		game_random[1] = 15;
		game_random[2] = 15;
		game_random[3] = 20;
		game_random[4] = 0;
	}
	else if (x_mouse >= x3  && x_mouse <= x3 + len2  && y_mouse >= h5 && y_mouse <= h5 + gao)
	{
		game_random[0] = 20;
		game_random[1] = 17;
		game_random[2] = 10;
		game_random[3] = 8;
		game_random[4] = 0;
	}

	else if (x_mouse >= x4  && x_mouse <= x4 + len2  && y_mouse >= h5 && y_mouse <= h5 + gao)
	{
		game_random[0] = 20;
		game_random[1] = 15;
		game_random[2] = 5;
		game_random[3] = 3;
		game_random[4] = 0;
	}
	else if (x_mouse >= x6  && x_mouse <= x6 + len1  && y_mouse >= h6 && y_mouse <= h6 + gao)
	{
		//确认
		scene = 5;

	}
	else if (x_mouse >= x5  && x_mouse <= x5 + len1  && y_mouse >= h6 && y_mouse <= h6 + gao)
	{
		game_random[0] = 0;
		game_random[1] = 0;
		game_random[2] = 0;
		game_random[3] = 0;
		game_random[4] = 0;

	}
	else if (x_mouse >= x7  && x_mouse <= x7 + gao  && y_mouse >= h1 && y_mouse <= h1 + gao)//一滴概率+
	{
		if (game_random[0] < 100 && game_random[0] + game_random[1] + game_random[2] + game_random[3] < 100)
			game_random[0] += 1;
	}
	else if (x_mouse >= x8  && x_mouse <= x8 + gao  && y_mouse >= h1 && y_mouse <= h1 + gao)//一滴概率-
	{
		if (game_random[0] > 0)
			game_random[0] -= 1;
	}
	else if (x_mouse >= x7  && x_mouse <= x7 + gao  && y_mouse >= h2 && y_mouse <= h2 + gao)//兩滴概率+
	{
		if (game_random[1] < 100 && game_random[0] + game_random[1] + game_random[2] + game_random[3] < 100)
			game_random[1] += 1;
	}
	else if (x_mouse >= x8  && x_mouse <= x8 + gao  && y_mouse >= h2 && y_mouse <= h2 + gao)//兩滴概率-
	{
		if (game_random[1] > 0)
			game_random[1] -= 1;
	}
	else if (x_mouse >= x7  && x_mouse <= x7 + gao  && y_mouse >= h3 && y_mouse <= h3 + gao)//三滴概率+
	{
		if (game_random[2] < 100 && game_random[0] + game_random[1] + game_random[2] + game_random[3] < 100)
			game_random[2] += 1;
	}
	else if (x_mouse >= x8  && x_mouse <= x8 + gao  && y_mouse >= h3 && y_mouse <= h3 + gao)//三滴概率-
	{
		if (game_random[2] > 0)
			game_random[2] -= 1;
	}
	else if (x_mouse >= x7  && x_mouse <= x7 + gao  && y_mouse >= h4 && y_mouse <= h4 + gao)//四滴概率+
	{
		if (game_random[3] < 100 && game_random[0] + game_random[1] + game_random[2] + game_random[3] < 100)
			game_random[3] += 1;
	}

	else if (x_mouse >= x8  && x_mouse <= x8 + gao  && y_mouse >= h4 && y_mouse <= h4 + gao)//四滴概率-
	{
		if (game_random[3] > 0)
			game_random[3] -= 1;
	}
}
void draw_scene_52()//第5模式第2界面方格设置绘制
{
	/*
  h1-h3为行、列、初始水及其+/-的y坐标,h4为大、中、小选项的y坐标,h5为重置/确认的y坐标
  gao为矩形高,len为矩形长
  x1为行、列、水的起始x坐标,x2-x4为大、中、小选项的x坐标,x5为重置,x6为确认x坐标,x7,x8为+,-的x坐标
  大、中、小与+、-的矩形长为gao是正方形
  row,column,num_water_I_begin为行、列、初始水的值
  */
	int h1 = 150, h2 = 270, h3 = 390, h4 = 510, h5 = 630;
	int gao = 80;//gao2为重置/确认的高度
	int len = 400;
	int x1 = 350;//行、列、水
	int x2 = 660, x3 = 780, x4 = 900;//选项
	int x5 = 200, x6 = 700;//重置/确认
	int x7 = 800, x8 = 920;//+ -
	BeginBatchDraw();
	setbkcolor(RGB(128, 128, 128));
	cleardevice();
	setfillcolor(WHITE);
	setlinecolor(WHITE);
	fillrectangle(0, 0, width, 100);//方格设置
	fillrectangle(x1, h1, x1 + len, h1 + gao);//行
	fillrectangle(x1, h2, x1 + len, h2 + gao);//列
	fillrectangle(x1, h3, x1 + len, h3 + gao);//初始水
	fillrectangle(x2, h4, x2 + gao, h4 + gao);//大
	fillrectangle(x3, h4, x3 + gao, h4 + gao);//中
	fillrectangle(x4, h4, x4 + gao, h4 + gao);//小
	fillrectangle(x5, h5, x5 + len, h5 + gao);//重置
	fillrectangle(x6, h5, x6 + len, h5 + gao);//确认
	fillrectangle(x7, h1, x7 + gao, h1 + gao);//行+
	fillrectangle(x8, h1, x8 + gao, h1 + gao);//行-
	fillrectangle(x7, h2, x7 + gao, h2 + gao);//列+
	fillrectangle(x8, h2, x8 + gao, h2 + gao);//列-
	fillrectangle(x7, h3, x7 + gao, h3 + gao);//初始水+
	fillrectangle(x8, h3, x8 + gao, h3 + gao);//初始水-
	settextcolor(BLACK);
	setbkmode(1);
	TCHAR s[40]; // 增加字符数组大小
	settextcolor(BLACK);
	swprintf_s(s, _T("方格设置"));//方格设置
	settextstyle(100, 0, _T("宋体"));
	outtextxy(450, 0, s);
	//设置行列水等内容
	settextstyle(50, 0, _T("宋体"));
	swprintf_s(s, _T("行     %2d"), row);//行
	outtextxy(x1 + 100, h1 + 15, s);
	swprintf_s(s, _T("+"));//行+
	outtextxy(x7 + 27, h1 + 15, s);
	swprintf_s(s, _T("-"));//行-
	outtextxy(x8 + 27, h1 + 15, s);
	swprintf_s(s, _T("列     %2d"), column);//列
	outtextxy(x1 + 100, h2 + 15, s);
	swprintf_s(s, _T("+"));//列+
	outtextxy(x7 + 27, h2 + 15, s);
	swprintf_s(s, _T("-"));//列-
	outtextxy(x8 + 27, h2 + 15, s);
	swprintf_s(s, _T("初始水   %2d"), num_water_I_begin);//初始水
	outtextxy(x1 + 50, h3 + 15, s);
	swprintf_s(s, _T("+"));//初始水+
	outtextxy(x7 + 27, h3 + 15, s);
	swprintf_s(s, _T("-"));//初始水-
	outtextxy(x8 + 27, h3 + 15, s);
	swprintf_s(s, _T("大"));//大
	outtextxy(x2 + 15, h4 + 15, s);
	swprintf_s(s, _T("中"));//中
	outtextxy(x3 + 15, h4 + 15, s);
	swprintf_s(s, _T("小"));//小
	outtextxy(x4 + 15, h4 + 15, s);
	swprintf_s(s, _T("重置"));//重置
	outtextxy(x5 + 150, h5 + 15, s);
	swprintf_s(s, _T("确认"));//确认
	outtextxy(x6 + 150, h5 + 15, s);
	settextcolor(YELLOW);
	swprintf_s(s, _T("一键设置"));//一键设置
	outtextxy(x1, h4 + 15, s);
	EndBatchDraw();
}
void mouse_scene_52()//第5模式第2界面方格设置鼠标
{
	/*
  h1-h3为行、列、初始水及其+/-的y坐标,h4为大、中、小选项的y坐标,h5为重置/确认的y坐标
  gao为矩形高,len为矩形长
  x1为行、列、水的起始x坐标,x2-x4为大、中、小选项的x坐标,x5为重置,x6为确认x坐标,x7,x8为+,-的x坐标
  大、中、小与+、-的矩形长为gao是正方形
  row,column,num_water_I_begin为行、列、初始水的值
  */
	Sleep(100);
	int h1 = 150, h2 = 270, h3 = 390, h4 = 510, h5 = 630;
	int gao = 80;
	int len = 400;
	int x1 = 350;//行、列、水
	int x2 = 660, x3 = 780, x4 = 900;//选项
	int x5 = 200, x6 = 700;//重置/确认
	int x7 = 800, x8 = 920;//+ -
	if (x_mouse >= x7 && x_mouse <= x7 + gao && y_mouse >= h1 && y_mouse <= h1 + gao)//行+
	{
		if (row < (MAX_LIST - 2))
			row += 1;
		else
			bug();
	}
	else if (x_mouse >= x8 && x_mouse <= x8 + gao && y_mouse >= h1 && y_mouse <= h1 + gao)//行-
	{
		if (row > 1)
			row -= 1;
	}
	else if (x_mouse >= x7 && x_mouse <= x7 + gao && y_mouse >= h2 && y_mouse <= h2 + gao)//列+
	{
		if (column < (MAX_LIST - 2))
			column += 1;
		else
			bug();
	}
	else if (x_mouse >= x8 && x_mouse <= x8 + gao && y_mouse >= h2 && y_mouse <= h2 + gao)//列-
	{
		if (column > 1)
			column -= 1;
	}
	else if (x_mouse >= x7 && x_mouse <= x7 + gao && y_mouse >= h3 && y_mouse <= h3 + gao)//水滴初始+
	{
		num_water_I_begin += 1;
	}
	else if (x_mouse >= x8 && x_mouse <= x8 + gao && y_mouse >= h3 && y_mouse <= h3 + gao)//水滴初始-
	{
		if (num_water_I_begin > 1)
			num_water_I_begin -= 1;
	}
	else if (x_mouse >= x2 && x_mouse <= x2 + gao && y_mouse >= h4 && y_mouse <= h4 + gao)//大
	{
		column = 30;
		row = 30;
	}
	else if (x_mouse >= x3 && x_mouse <= x3 + gao && y_mouse >= h4 && y_mouse <= h4 + gao)//中
	{
		column = 20;
		row = 20;
	}
	else if (x_mouse >= x4 && x_mouse <= x4 + gao && y_mouse >= h4 && y_mouse <= h4 + gao)//小
	{
		column = 10;
		row = 10;
	}
	else if (x_mouse >= x5 && x_mouse <= x5 + len && y_mouse >= h5 && y_mouse <= h5 + gao)
	{
		num_water_I_begin = 10;
		row = 10;
		column = 10;
		
		//重置游戏界面
	}
	else if (x_mouse >= x6 && x_mouse <= x6 + len && y_mouse >= h5 && y_mouse <= h5 + gao)
	{
		scene = 5;

	}

}
void draw_scene_53()//第5模式第3界面颜色效果设置绘制
{
	/*
h1为点击效果选项的y坐标,h2为时间限制选项的y坐标,h3为颜色选择选项的y坐标,h4为重置/确认的y坐标
gao为矩形高,len1为点击效果,len2为时间限制,len3为颜色选择,len4为重置/确认
x1-x3为点击效果选项的x坐标,x4-x5为时间限制选项的x坐标,x6-x9为颜色选择选项的x坐标,x10-x11为重置/确认的x坐标
*/
	int h1 = 200, h2 = 330, h3 = 460, h4 = 600;
	int gao = 80;
	int len1 = 150, len2 = 200, len3 = 120, len4 = 400;//len1为点击效果,len2为时间限制,len3为颜色选择,len4为重置/确认
	int x1 = 550, x2 = 750, x3 = 950;//点击效果选项
	int x4 = 600, x5 = 850;//时间限制
	int x6 = 540, x7 = 690, x8 = 840, x9 = 990;//颜色选择
	int x10 = 200, x11 = 700;//重置/确认
	BeginBatchDraw();
	setbkcolor(RGB(128, 128, 128));
	cleardevice();
	setfillcolor(WHITE);
	setlinecolor(WHITE);
	fillrectangle(0, 0, width, 100);//模式
	fillrectangle(x1, h1, x1 + len1, h1 + gao);//点击效果-普通
	fillrectangle(x2, h1, x2 + len1, h1 + gao);//点击效果-炸弹
	fillrectangle(x3, h1, x3 + len1, h1 + gao);//点击效果-核弹
	fillrectangle(x4, h2, x4 + len2, h2 + gao);//时间限制-有
	fillrectangle(x5, h2, x5 + len2, h2 + gao);//时间限制-无
	fillrectangle(x6, h3, x6 + len3, h3 + gao);//颜色选择-绿色
	fillrectangle(x7, h3, x7 + len3, h3 + gao);//颜色选择-红色
	fillrectangle(x8, h3, x8 + len3, h3 + gao);//颜色选择-紫色
	fillrectangle(x9, h3, x9 + len3, h3 + gao);//颜色选择-蓝色
	fillrectangle(x10, h4, x10 + len4, h4 + gao);//重置
	fillrectangle(x11, h4, x11 + len4, h4 + gao);//确认
	settextcolor(BLACK);
	setbkmode(1);
	TCHAR s[40]; // 增加字符数组大小
	settextcolor(BLACK);
	swprintf_s(s, _T("模式"));//模式
	settextstyle(100, 0, _T("宋体"));
	outtextxy(550, 0, s);
	//具体内容
	if (water_mode == 1)
		settextcolor(RED);
	settextstyle(50, 0, _T("宋体"));
	swprintf_s(s, _T("普通"));//普通
	outtextxy(x1 + 25, h1 + 15, s);//575,215
	settextcolor(BLACK);
	if (water_mode == 2)
		settextcolor(RED);
	swprintf_s(s, _T("炸弹"));//炸弹
	outtextxy(x2 + 25, h1 + 15, s);//775,215
	settextcolor(BLACK);
	if (water_mode == 3)
		settextcolor(RED);
	swprintf_s(s, _T("核弹"));//核弹
	outtextxy(x3 + 25, h1 + 15, s);//975,215
	settextcolor(BLACK);
	if(time_open)
		settextcolor(RED);
	swprintf_s(s, _T("有"));//有
	outtextxy(x4 + 75, h2 + 15, s);//625,345
	settextcolor(RED);
	if(time_open)
		settextcolor(BLACK);
	swprintf_s(s, _T("无"));//无
	outtextxy(x5 + 75, h2 + 15, s);//875,345
	settextcolor(BLACK);
	if (rgb_now == 1)
		settextcolor(GREEN);
	swprintf_s(s, _T("绿色"));//绿色
	outtextxy(x6 + 10, h3 + 15, s);//550,475
	settextcolor(BLACK);
	if (rgb_now == 2)
		settextcolor(RED);
	swprintf_s(s, _T("红色"));//红色
	outtextxy(x7 + 10, h3 + 15, s);//700,475
	settextcolor(BLACK);
	if (rgb_now == 3)
		settextcolor(RGB(145, 39, 229));
	swprintf_s(s, _T("紫色"));//紫色
	outtextxy(x8 + 10, h3 + 15, s);//850,475
	settextcolor(BLACK);
	if (rgb_now == 4)
		settextcolor(BLUE);
	swprintf_s(s, _T("蓝色"));//蓝色
	outtextxy(x9 + 10, h3 + 15, s);//1000,475
	settextcolor(BLACK);
	swprintf_s(s, _T("重置"));//重置
	outtextxy(x10 + 150, h4 + 15, s);//350,615
	swprintf_s(s, _T("确认"));//确认
	outtextxy(x11 + 150, h4 + 15, s);//850,615
	settextcolor(YELLOW);
	swprintf_s(s, _T("点击效果"));//点击效果
	outtextxy(300, h1 + 15, s);
	swprintf_s(s, _T("时间限制"));//时间限制
	outtextxy(300, h2 + 15, s);
	swprintf_s(s, _T("颜色选择"));//颜色选择
	outtextxy(300, h3 + 15, s);
	EndBatchDraw();
}
void mouse_scene_53()//第5模式第3界面颜色效果设置鼠标
{
	/*
h1为点击效果选项的y坐标,h2为时间限制选项的y坐标,h3为颜色选择选项的y坐标,h4为重置/确认的y坐标
gao为矩形高,len1为点击效果,len2为时间限制,len3为颜色选择,len4为重置/确认
x1-x3为点击效果选项的x坐标,x4-x5为时间限制选项的x坐标,x6-x9为颜色选择选项的x坐标,x10-x11为重置/确认的x坐标
*/
	Sleep(100);
	int h1 = 200, h2 = 330, h3 = 460, h4 = 600;
	int gao = 80;
	int len1 = 150, len2 = 200, len3 = 120, len4 = 400;//len1为点击效果,len2为时间限制,len3为颜色选择,len4为重置/确认
	int x1 = 550, x2 = 750, x3 = 950;//点击效果选项
	int x4 = 600, x5 = 850;//时间限制
	int x6 = 540, x7 = 690, x8 = 840, x9 = 990;//颜色选择
	int x10 = 200, x11 = 700;//重置/确认
	if (x_mouse >= x1 && x_mouse <= x1 + len1 && y_mouse >= h1 && y_mouse <= h1 + gao)//普通
	{
		water_mode = 1;
	}
	else if (x_mouse >= x2 && x_mouse <= x2 + len1 && y_mouse >= h1 && y_mouse <= h1 + gao)//炸彈
	{
		water_mode = 2;
	}
	else if (x_mouse >= x3 && x_mouse <= x3 + len1 && y_mouse >= h1 && y_mouse <= h1 + gao)//核彈
	{
		water_mode = 3;
	}
	else if (x_mouse >= x4 && x_mouse <= x4 + len2 && y_mouse >= h2 && y_mouse <= h2 + gao)//有
	{
		time_open = 1;
	}
	else if (x_mouse >= x5 && x_mouse <= x5 + len1 && y_mouse >= h2 && y_mouse <= h2 + gao)//無
	{
		time_open = 0;
	}
	else if (x_mouse >= x6 && x_mouse <= x6 + len3 && y_mouse >= h3 && y_mouse <= h3 + gao)//綠色
	{
		rgb_now = 1;
	}
	else if (x_mouse >= x7 && x_mouse <= x7 + len3 && y_mouse >= h3 && y_mouse <= h3 + gao)//紅色
	{
		rgb_now = 2;
	}
	else if (x_mouse >= x8 && x_mouse <= x8 + len3 && y_mouse >= h3 && y_mouse <= h3 + gao)//紫色
	{
		rgb_now = 3;
	}
	else if (x_mouse >= x9 && x_mouse <= x9 + len3 && y_mouse >= h3 && y_mouse <= h3 + gao)//藍色
	{
		rgb_now = 4;
	}
	else if (x_mouse >= x10 && x_mouse <= x10 + len4 && y_mouse >= h4 && y_mouse <= h4 + gao)//重置
	{
		rgb_now = 1;
		time_open = 1;
		water_mode = 1;
		
	}
	else if (x_mouse >= x11 && x_mouse <= x11 + len4 && y_mouse >= h4 && y_mouse <= h4 + gao)//確認
	{
		scene = 5;
		
	}
}
void draw_scene()//不同非游戏界面场景绘制
{
	if (scene == 0)
	{
		draw_scene_0();
	}
	else if (scene == 1)
	{
		draw_scene_1();
	}
	else if (scene == 2)
	{
		draw_scene_2();
	}
	else if (scene == 3)
	{
		draw_scene_3();
	}
	else if (scene == 4)
	{
		draw_scene_4();
	}
	else if (scene == 5)
	{
		draw_scene_5();
	}
	else if (scene == 51)
	{
		draw_scene_51();
	}
	else if (scene == 52)
	{
		draw_scene_52();
	}
	else if (scene == 53)
	{
		draw_scene_53();
	}
}
void score_max_update()//历史最高分更新
{
	if (water_mode == 1)
	{
		if (mode_4 == 1)
		{
			if (score_max[1] < currentValue)
				score_max[1] = currentValue;
		}
		else if (mode_4 == 2)
		{
			if (score_max[2] < currentValue)
				score_max[2] = currentValue;
		}
		else if (mode_4 == 3)
		{
			if (score_max[3] < currentValue)
				score_max[3] = currentValue;
		}
	}
	else if (water_mode == 2)
	{
		if (mode_4 == 1)
		{
			if(score_max[4]<play_time*100)
				score_max[4] = (int)(play_time*100);
		}
		else if (mode_4 == 2)
		{
			if (score_max[5] < play_time * 100)
				score_max[5] = (int)(play_time * 100);
		}
		else if (mode_4 == 3)
		{
			if (score_max[6] < play_time * 100)
				score_max[6] = (int)(play_time * 100);
		}
	}
	else if (water_mode == 3)
	{
		if (mode_4 == 1)
		{
			if (score_max[7] < play_time * 100)
				score_max[7] = (int)(play_time * 100);
		}
		else if (mode_4 == 2)
		{
			if (score_max[8] < play_time * 100)
				score_max[8] = (int)(play_time * 100);
		}
		else if (mode_4 == 3)
		{
			if (score_max[9] < play_time * 100)
				score_max[9] = (int)(play_time * 100);
		}
	}
	else if(water_mode == 4)
	{
		if (mode_4 == 1)
		{
			if (score_max[10] < num_water_boom)
				score_max[10] = num_water_boom;
		}
		else if (mode_4 == 2)
		{
			if (score_max[11] < num_water_boom)
				score_max[11] = num_water_boom;
		}
		else if (mode_4 == 3)
		{
			if (score_max[12] < num_water_boom)
				score_max[12] = num_water_boom;
		}
	}
	// 写入数据到文件
	FILE* fp;
	fopen_s(&fp, "test.txt", "w"); // 打开文件，以写方式打开
	if (fp == NULL) {
		exit(0);
	}
	else 
	{
		for (int i = 0; i < 13; i++) {
			fprintf(fp, "%d ", score_max[i]); // 将数据写入文件
		}
	}
	fclose(fp); // 关闭文件
}
